JQ full selection setting and setting selected

Source: Internet
Author: User

Check Data frame

<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >Botanical Gardens<input type= "checkbox"class= "CK" value= "Botanical Garden"/>Parks<input type= "checkbox"class= "CK" value= "Park"/>Hospital<input type= "checkbox"class= "CK" value= "Hospital"/>Restaurant<input type= "checkbox"class= "ck" value= "Restaurant"/></div><br/><div><input type= "button" value= "Take Value" id= "BTN"/></div &GT;&LT;BR/><div>Please enter a region: <input type= "text" id= "qy"/><input type= "button" value= "Settings Select" id= "Szxz"/></div></body>< Script type= "Text/javascript" >$ (document). Ready (function(e) {$ ("#qx"). Click (function(){        //find selection of the Select All button        varxz=$ (This). Prop ("Checked"); //selects all of the check boxes in the check box list to select All selected states$ (". CK"). Prop ("Checked",XZ); })        $("#btn"). Click (function(){                        varck=$ (". CK"));  for(vari=0;i<ck.length;i++)            {                //take the jquery object//ck.eq (i). Prop ("checked"); Fetch DOM Object//ck[i].checked                                if(Ck.eq (i). Prop ("checked")) {alert (CK. EQ (i).Val ()); }            }            })                $("#szxz"). Click (function(){                //gets the value entered by the user        varqy=$ ("#qy").Val (); //Set the selected        varck=$ (". CK")); CK. Prop ("Checked",false);  for(vari=0;i<ck.length;i++)        {            if(Ck.eq (i). val () = =qy) {CK. EQ (i). Prop ("Checked",true); }            }                })                                });</script>View Code

Single-Selection data frame

<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >Botanical Gardens<input type= "Radio" name= "QY"class= "CK" value= "Botanical Garden"/>Parks<input type= "Radio" name= "QY"class= "CK" value= "Park"/>Hospital<input type= "Radio" name= "QY"class= "CK" value= "Hospital"/>Restaurant<input type= "Radio" name= "QY"class= "ck" value= "Restaurant"/></div><br/><div><input type= "button" value= "Check value" id= "BTN"/></div ></body><script type= "Text/javascript" >$ (document). Ready (function(e) {$ ("#btn"). Click (function(){                varck=$ (". CK")); //using the For loop output         for(vari=0;i<ck.length;i++)        {                if(Ck.eq (i). Prop ("checked")) {alert (CK. EQ (i).Val ()); }        }                })});</script>View Code

Drop-down Data bar

<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >Please enter:<input type= "text" id= "zhi"/><input type= "button" value= "Settings Check" id= "Szxz"/></div></body>< Script type= "Text/javascript" >$ (document). Ready (function(e) {$ ("#btn"). Click (function() {alert ($ ("#qy").Val ()); })            $("#szxz"). Click (function(){                varzhi=$ ("#zhi").Val (); varop=$ ("option"); /*For (Var i=0;i<op.length;i++) {//op.eq (i). Prop ("selected");                if (Op.eq (i). Val () ==zhi) {Op.eq (i). Prop ("selected", true); }        }*/                $("#qy").val (zhi); })});</script>View Code

JQ full selection setting and setting selected

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.