Home  >  Article  >  Web Front-end  >  jquery select/cancel all selection in one sentence_jquery

jquery select/cancel all selection in one sentence_jquery

WBOY
WBOYOriginal
2016-05-16 18:09:58955browse

1、当然要引入jquery文件啦。
2、建立函数
var check_all = function(obj,name){$(":checkbox[name='" name "']").attr("checked",obj.checked); }
3、使用

复制代码 代码如下:








全选













……



多组的JQUERY选中与取消
复制代码 代码如下:






选中GROUPA

GROUPA:

11

22

33


选中GROUPB

GROUPB:

44

55

66





另外的补充代码:
引用Jquery 库jquery-1.4.1-vsdoc.js 等

Jquery脚本代码——————————————————————
复制代码 代码如下:

$(function() {
$('#inputCheck').click(function() {
$("input[name='Checkbox1']").attr("checked", $(this).attr("checked"));
});
}); // 全选

$(function() {
$("#select_reverse").click(function() {
$("input[name='Checkbox1']").each(function(idx, item) {
$(item).attr("checked", !$(item).attr("checked"));
})
});
});//反选

html 前台代码————————————————————————
[code]
全选
反选






[html]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn