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

点击选中项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 }


用change方法就可以了


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

$(document).on("change",":checkbox:checked",function(){
    var $this=$(this);
    //写自己的逻辑。。。
});
【热门文章】
【热门文章】