发布时间:2018-04-25作者:laosun阅读(1446)
实现方式:
<th><label><input type="checkbox" name="all" child="index_" class="ace"><span class="lbl"></span></label></th> <th><label><input type="checkbox" name="all" child="index2_" class="ace"><span class="lbl"></span></label></th>
以下是循环出来的多列数据: <td><label><input type="checkbox" name="id" id="index_" class="ace"><span class="lbl"></span></label></td> <td><label><input type="checkbox" name="id" id="index2_" class="ace"><span class="lbl"></span></label></td>
<script type="text/javascript"> $(document).ready(function(e) { $("input[name=all]").click(function() { var idName = $(this).attr("child"); if ($(this).is(':checked')) { $("input[id=" + idName + "]").prop("checked", true); } else { $("input[id=" + idName + "]").prop("checked", false); } }); }); //jquery 获取选中的值 function batchSpiderTo(id) { $("input:checkbox[id=" + id + "]:checked").each(function() { alert($(this).attr("attr")); }); } </script>
版权属于: 技术客
原文地址: https://www.sunjs.com/article/detail/0ae5ba46d3734cc7921f0dbc824d9382.html
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
关键字: jquery 前端 源码 javascript