Home >Web Front-end >JS Tutorial >jquery, js operation checkbox all selection and inverse selection_javascript skills

jquery, js operation checkbox all selection and inverse selection_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:55:441091browse

Operate the checkbox, select all and invert the selection

Copy the code The code is as follows:

//Select all
function checkAll() {
$('input[name="TheID"]').attr("checked", "checked");
}
//Inverse selection
function uncheckAll( ) {
$('input[name="TheID"]').each(function() {
this.checked = !this.checked;
})
}
/ /Get the selected item
function getCheck(){
var check = $('input[name="TheID"]:checkbox').map(function() {
return $(this). val();
}).get().join(',');
return check;
}
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