Home  >  Article  >  Web Front-end  >  Notes on some problems encountered when jquery makes check boxes in projects_jquery

Notes on some problems encountered when jquery makes check boxes in projects_jquery

WBOY
WBOYOriginal
2016-05-16 17:14:45730browse
About the checkbox

When I was making a checkbox yesterday, I thought it should be quite simple at first. I took it for granted that the main function is to click a button, such as selecting all This is a function, and then all the following lists are selected for the effect.

Later, I still encountered a lot of problems in practice. Note that in the input checkbox, it is not possible to use the ordinary attr attribute to judge, because the value of checked is checked, and only the prop attribute can be used. Change! ! ! ! See the api documentation, and later found out in Baidu that this has been explained in the official api. Attached is the api address of a prop in jquery http://api.jquery.com/prop/, one of which is a classic example , comparing attr and prop by judging is(":checked"), it is worth taking a look. The code was changed later;
Copy code The code is as follows:

$("#main-manage").on('click',"#selectAll", function(event) {
$("#xunTable"). find('input').not(":disabled").each(function(index, el) {
if($("#selectAll").is(":checked")){
$ (this).prop('checked', 'true');
}
else{
$(this).prop('checked', 'false');
$(this) .removeAttr('checked');
}
});
});
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