Tag:button Get Disable javascrip code by ID oct min Cancel check
1//NOTE: When operating the Checked,disabled property of a CheckBox jquery1.6 previous version with attr,1.6 above (included) is recommended Prop 2 3//1, get a checkbox by ID 4 $ ("#cbChec Kbox1 "); 5 6//2, get all checkboxes 7 $ ("Input[type= ' checkbox ']"),//or 8 $ ("Input[name= ' CB ')"); 9 10//3, get all selected Checkbox11 $ ("input:checkbox:checked"),//or12 $ ("input:[type= ' checkbox ']:checked");//or13 $ ("input[type= ' checkbox ']:checked");//or14 $ ("input:[name= ' ck ']:checked"); 15 16//4, Get CheckBox value 17//With. Val (), For example: $ ("#cbCheckbox1"). Val (); 19 20 21//5, get multiple selected checkbox values of var vals = [];23 $ (' input:checkbox:checked ') . each (the function (index, item) {Vals.push ($ (this). Val ()); 25}); 26 27//6, determines whether the checkbox is selected (jquery 1.6 Previous version This is used for $ (this). attr ("Checked")) ("#cbCheckbox1"). Click (function () {if ($ (). Prop ("checked")) {30 Alert ("Checked"), or else {alert ("unchecked"), 33}34}), 35 36//7, set checkbox to selected 37 $ (' Input:checkbox '). attr ("Checked", ' ChEcked ');//or38 $ (' Input:checkbox '). attr ("Checked", true); 39 40//8, set checkbox to uncheck the status of $ (' Input:checkbox '). attr ("Checked", "");//or42 $ (' Input:checkbox '). attr ("checked", false); 43 44//9, set checkbox to Disabled (jquery<1.6 with Attr,jqu ery>=1.6 recommended prop) $ ("Input[type= ' checkbox ')"). attr ("Disabled", "disabled");//or46 $ ("input[type= ' checkbox ']") . attr ("Disabled", true);//or47 $ ("input[type= ' checkbox ']"). Prop ("Disabled", true);//or48 $ ("input[type= ' checkbox ') "). Prop (" Disabled "," disabled "); 49 50//10, set checkbox enabled (jquery<1.6 with attr,jquery>=1.6 recommended prop) (Input[ty pe= ' checkbox '). Removeattr ("Disabled");//or52 $ ("input[type= ' checkbox ']") attr ("disabled", false);//or53 $ ("Inpu T[type= ' checkbox ']. Prop ("Disabled", "" ");//or54 $ (" input[type= ' checkbox '] "). Prop (" disabled ", false);
The code is as follows:
1 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 2 Various actions of the jquery on a checkbox