May 13 jquery Basics

Source: Internet
Author: User

Basic knowledge of jquery

class= "BB" >22</div><divclass= "BB" >33</div><divclass= "BB" >44</div><input type= "text" Name= "CC" bs= "dd"/></body><script type= "Text/javascript" >$ (document). Ready (function(e) {//Find the element based on the ID, the specific jquery object is found, if you want to fetch the DOM object, then the object of index 0 is taken   varJD = $ ("#aa");//by ID   varJC = $ (". BB");//according to class   varJdiv = $ ("div");//according to the label name   varIP = $ ("input[name=cc]");//Filter by attributes in square brackets    for(vari=o;i<jc.length;i++) {JC. EP (i);//EP is the first of several jquery objects inside an array   }   //action content//1. Non-TABLE elementJd.text ();//value method, take contentJd.text ("AA");//method of assigning valuesJd.html ();//take the value method, take the codeJd.html ("VV");//assignment method//2. Table cell ElementJd.val ();//Take valueJd.val ("")//Assignment//Operation PropertiesJd.attr ("BS", "AA");//Setting PropertiesJd.attr ("BS");//Get PropertiesJd.removeattr ("BS");//Remove attributes//action styleJd.css ("Background-color", "green")     //add an event to an element$ ("#aa"). Click (function() {alert ("AA");   }); //adding events to multiple elements$ (". BB"). Click (function() {Alert ($ (this).text ());   }); //set the same style for multiple elements$ (". BB"). CSS ("Color", "brown"));});</script>

The all-in-choice application of jquery

Select All<inputclass= "T" type= "checkbox" value= "AA"/>AA<inputclass= "T" type= "checkbox" value= "BB"/>BB<inputclass= "T" type= "checkbox" value= "CC"/>cc<inputclass= "T" type= "checkbox" value= "dd"/>DD<inputclass= "T" type= "checkbox" value= "ee"/>ee<input type= "button" value= "Test" id= "btn"/><input type= "text" id= "Tex"/><input type= "button" value= " Set check "id=" sel "/></body><script type=" Text/javascript ">$ (document). Ready (function(e) {//Select All$ ("#all"). Click (function(){    varCK = $ (". T"); varXZ = $ (this) [0].checked; CK. Prop ("Checked",XZ);   }); //the selected value$ ("BTN"). Click (function(){   varCK = $ (". T");  for(vari=0;i<ck.length;i++)   {     if(Ck.eq (i). Prop ("checked"))//Ck.eq (i) [0].checked{alert (CK. EQ (i).Val ());   }   }    }); //sets an item selected   $("#sel"). Click (function(){    varv = $ ("#tex").Val (); varCK = $ (". T"); CK. Prop ("Checked",false);  for(vari=0;i<ck.length;i++)    {        if(Ck.eq (i). val () = =v) {CK. EQ (i). Prop ("Checked",true)        }    }            })});

May 13 jquery Basics

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.