Home > Web Front-end > JS Tutorial > body text

Simple and practical example of selecting all and inverting the selection button_jquery

WBOY
Release: 2016-05-16 17:19:36
Original
1261 people have browsed it
Copy code The code is as follows:

//Select all button processing
$(function(){
//Click to select all
$("#checkAll").click(function () {//When clicking on the select all box
var flag = $("#checkAll").is(" :checked"); // Determine the status of the select all button
var checkItems=document.getElementsByName("checkItem");
for(var i=0;i checkItems[i].checked = flag;
}
});
//Click on the sub-item
$("input:checkbox[name='checkItem']").each(function( ){
$(this).click(function(){
if($("input:checkbox[name='checkItem']:checked").length==$("input:checkbox[name ='checkItem']").length){
document.getElementById("checkAll").checked = true;
}else{
document.getElementById("checkAll").checked = false;
}
});
});
});
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!