In practice, I still encountered a lot of problems. Note that in the input checkbox, it is not possible to use the ordinary attr attribute to judge. Because the checked value is checked, make a note.
Check box
When I made a check box yesterday, I thought it should be quite simple at first. taking it for granted, the main function is to click a button, for example, to select this function all, then all the following lists are selected.
Later, I encountered a lot of problems in practice. Note that in the input checkbox, it is impossible to judge using the ordinary attr attribute, because the checked value is checked, this attribute can be changed only when prop is used !!!! See the api documentation. Later, Baidu found that this has been explained in the official api. The following is an example of how to attach a prop api address (": checked") in jquery to attr, prop, it is worth reading and later the code is changed;
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 ');
}
});
});