20151227:jquery element Selection and value < turn >

Source: Internet
Author: User

One: Common selector: $ ("#id")//by ID//returns a single element$("Div")//by label$(". CLS")//class Selector$("Div.cls")//tag plus class selector$("*")//Select all the elements$( This)//own$("Div,p,a")//get a collection of all tags$("Div P")//all the <p> under the Div, no matter how many layers [descendants]$("div>p")//get the most direct p [son]$("div+p")//the first element below the sibling node [brother]//equivalent to. Next ();$("div~p")//all the following sibling nodes of the layer//equivalent to. nextall ();II: Commonly used filters:: EQ (): Index//1th element $ (' p:eq (0) '): Not (): unsatisfied"Selector Selector"elements: First: One: Last: Final: animated: All elements that are animating: contains (text): Select the element that contains text//no quotes like effect: Empty: Select a blank element that does not contain elements or text//<div></div> test pass, line break should also count characters, cannot be selected (browser problem, CSS problem): Has (selector): Select the element that contains the matching element:p arent: Select the element that contains the child element or text: Hidden: Select all invisible elements $ (": Hidden")//elements that include Display:none: Visible: Select all visible Elements $ ("div:visible")    :checked: selected: selecetd: Selected [ID]: Select the element that owns the id attribute//("Div[style]"). Hide (2000); Test failed.//("Div[id]"). Hide (2000); test pass[id=text]: Select an element with ID of text [ID!=text]: Select an element with an ID other than text [ID^=T]: Select an element whose ID starts with T [id$=T]: Select an element with an ID that ends with T [ID*=text]: Select the element whose ID contains text three: Select elements: About DOM objects and jquery objects: the latter is the encapsulation of the former $ ("#sel"): The jquery object with the ID sel, actually returns the array. $("#sel")[0]: Is the DOM object encapsulated within a jquery object with ID sel, which is the element itself. $(". Class"): Is a collection of jquery objects of class class four: Gets the selected value of select: $ ("#sel"). Val (): Gets the selected value of the Select. Five: Iterate through the same checkbox with the same class name to get multiple checkbox check values:varCK = $ (". Check");  for(varI=0; I <ck.length; i++)    {        if(Ck.eq (i) [0].checked==true{alert (Ck.eq (i). Val ()); } VI: Traverse the same class name RadioButton, get multiple RadioButton selected values:varCK = $ (". Radio");  for(varI=0; I <ck.length; i++)    {        if(Ck.eq (i) [0].checked==true{alert (Ck.eq (i). Val ()); }    }

This article is reproduced from teacher Li

20151227:jquery element Selection and value < turn >

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.