"全部检查”;不选中复选框
"check all" not checking checkboxes
我在尝试检查所有函数时使用了JQuery,因为这个js没有显示所有被检查的字段,但当我删除那个js时,滑块受到了影响。所以请试着解决我的问题,我使用了无冲突函数,但它不起作用。
<script type="text/javascript">
jQuery.noConflict()
jQuery.ready(function() {
jQuery("#selectall").click(function() {
$('.case').attr('checked', this.checked);
}); // prototype
});
</script>
<div class="accordion-heading">
<input type="checkbox" id="selectall" name="sample" class="selectall" />
<div style="float:left; "> <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion1" href="#collapse_1" /> Admin Module
</div>
</a>
</div>
<div id="collapse_1" class="accordion-body collapse in">
<div class="accordion-inner" id="checkboxlist">
<table class="table table-bordered table-hover" id="test" align="center" style="width:100%">
<tr>
<th width="450"><strong>Form Name</strong>
</th>
<th width="150"><strong>select</strong>
</th>
<th width="150"><strong>Edit</strong> </th>
<th width="150"><strong>Delete</strong>
</th>
<th width="150"><strong>View</strong>
</th>
</tr>
<tr>
<td style="padding-left:20%">Authentication</td>
<td style="padding-left:8%">
<input type="checkbox" id="case1" name="emailid[]" value="" class="case" /> </td>
<td style="padding-left:8%">
<input type="checkbox" id="case1" name="emailid[]" value="" class="case" />
</td>
<td style="padding-left:8%">
<input type="checkbox" id="case1" name="emailid[]" value="" class="case" /> </td>
<td style="padding-left:8%">
<input type="checkbox" id="case1" name="emailid[]" value="" class="case" />
</td>
</tr>
你只是做错了,只有当前文档有一个就绪的处理程序,你应该使用prop
来设置一个属性,并在change
事件是复选框时侦听它。
jQuery(function($) {
$("#selectall").on('change', function () {
$('.case').prop('checked', this.checked);
});
});
记住在脚本之前实际包含jQuery
FIDDLE
如果我理解正确,这就是处理jQuery.noConflict()的方法:
<script type="text/javascript">
jQuery.noConflict();
// Here, $ is a reference to whatever it was assign (if I understand correctly, it is prototypeJS)
(function($) {
// Here, $ is a reference to jQuery
$(function($) {
$("#selectall").click(function() {
$('.case').attr('checked', this.checked);
}); // jQuery
});
})(jQuery);
// Here, $ is a reference to whatever it was assign (if I understand correctly, it is prototypeJS)
</script>
相关文章:
- JavaScript-切换“;全部检查”;复选框true/false
- 检查数据库中复选框的值
- JQuery:如何检查某个类的所有复选框是否都在表单中选中
- knockoutjs,复选框是有延迟的检查
- 关于复选框检查的困惑
- 复选框检查器在表中不起作用.代码在没有表标记的情况下工作
- 在复选框检查的更改功能上需要计算一个值
- 复选框检查事件验证没有 Javascript
- 我的JavaScript在复选框检查中有一些错误
- 如何使用angularjs根据复选框检查和取消选中来制作chckbox列表
- 如何使用AngularJS通过已检查的值进行复选框检查
- 根据复选框检查并设置url变量
- 如何在JavaScript/jQuery中弹出模态并运行复选框检查
- JavaScript复选框检查相关问题
- 如何使用输入复选框检查特定图像
- 复选框检查验证
- 数组复选框.检查javascript不工作
- 用于复选框检查的Java字符串到JavaScript字符串数组
- 复选框检查缓慢
- 我有麻烦得到复选框.检查工作