JQuery sets all checkbox options (different from jQuery versions) and checkboxjquery
JQuery sets all checkbox options. There are various articles on the Internet, but why is it ineffective when we use their code?
If your code has no errors at all, do not worry about the correctness of your code first. Maybe it's just that the jQuery version you use is different.
Many versions of jQuery will make some improvements to some small functions, such as the checkbox selection.
The line version jquery1.9.1 of jQuery's changes to the checkbox.
Before jquery1.9.1, select all of the following options:
$ ('# Checkbox'). attr ('checked', true) $ (' # checkbox'). attr ('checked', false)
After jquery1.9.1, select all of them as follows:
$ ('# Checkbox'). prop ('checked', true) $ (' # checkbox'). prop ('checked', false)
Determine whether or not to select. After my experiment:
It can only be used before jquery1.9.1.
$ ("Input [name = 'chk _ all']"). attr ('checked ');
It can be used later.
$ ("Input [name = 'chk _ all']"). is ('checked'); and $ ("input [name = 'chk _ all']"). prop ('checked ');
If any error occurs, correct it.