December 21, 2015 10:52:51 Monday
Target, click on the current Checbox to determine whether the current checkbox is selected after the click.
Html:
<input type= "checkbox" onclick= "Contracts_checkall ()" id= "Contracts_checkall" > select All
Js:
1 var checkall = $ ("#contracts_checkall"). attr (' checked '); 2 var checkall_value1 = $ ("#contracts_checkall"). Val (); 3 var checkall_value2 = $ (' #contracts_checkall '). Is (': Checked '); 4 Console.log (checkall); 5 Console.log (checkall_value1); 6 Console.log (checkall_value2);
First time click:
1 undefined 2 undefined 3 on 4 true
Second click:
1 undefined 2 undefined 3 on 4 false
In summary, the IS () method can be used to determine the status of the current check box, even if there are no related properties
Select All/Deselect All
1 functionContracts_checkall ()2 {3 varCheckall = $ (' #contracts_checkall '). Is (': Checked '));6$ ("Input[name= ' contract[]" "). each (7 function () {8 This. checked=Checkall;9 //$ (this). attr (' checked ', checkall);//The first check and cancel are successful, and the selection will not work.Ten } One ); A}
jquery checkbox check box multiple clicks to determine the selected state, as well as the Select all/Cancel code example