点击选中项input点击按钮做什么,在点击别的选中input点击按钮做什么js如何写?

<table width="300px"height="100px"border="1px">
<tr>
  <td><input type="checkbox"></td>
  <td>aaa</td>
</tr>
<tr>
  <td><input type="checkbox"></td>
  <td>bbb<td>
</tr>
<tr>
  <td><input type="checkbox"></td>
  <td>cccc</td>
</tr>
</table>
<button>按钮</button>

checkbox只能选一个,就是点击选中项{dong something },在点击别的选中项点击按钮{ dong something }

阅读 3.4k
2 个回答

用change方法就可以了

<input type="checkbox">    aaa
<input type="checkbox">    bbb    
<input type="checkbox"> ccc

$(document).on("change",":checkbox:checked",function(){
    var $this=$(this);
    //写自己的逻辑。。。
});
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题