JQuery learning note selector 5

Source: Internet
Author: User

Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Script src = "js/jquery-1.3.2.js"> </script>
<Script type = "text/javascript"> <! --
$ (Function (){
$ ("# AFirst"). click (function (){
$ ("Div [id]"). each (function (){
Certificate (this).css ("background", "#773300 ");
})
})
$ ("# ASecond"). click (function (){
$ ("Div [id = div2]"). each (function (){
Certificate (this).css ("background", "# 8833ff ");
})
})
$ ("# AThird"). click (function (){
$ ("Div [id! = Div2] "). each (function (){
Certificate (this).css ("background", "#87f289 ");
})
})
$ ("# AFourthly"). click (function (){
$ ("Div [name ^ = DIV]"). each (function (){
Certificate (this).css ("background", "#140586 ");
})
})
$ ("# AFifthly"). click (function (){
$ ("Div [name $ = ly]"). each (function (){
Certificate (this).css ("background", "#930584 ");
})
})
$ ("# ASixth"). click (function (){
$ ("Div [name * = th]"). each (function (){
Certificate (this).css ("background", "#099483 ");
})
})
$ ("# ASeventh"). click (function (){
$ ("Div [id] [name! = Effecthly] [name * = I] "). each (function (){
Certificate (this).css ("background", "#938607 ");
})
})
})
// --> </Script>
<Title> untitled document </title>
</Head>
<Body>
<A href = "#" onclick = "javascript: location. reload ();"> Reset </a>
<Div id = "div1" name = "DIV_First"> div1 </div>
<Div id = "div2" name = "DIV_Second"> div2 </div>
<Div id = "div3" name = "DIV_Third"> div3 </div>
<Div id = "div4" name = "DIV_Fourthly"> div4 </div>
<Div id = "div5" name = "incluthly"> div5 </div>

<A href = "#" id = "aFirst"> set the background color of all DIV elements on the page </a> |
<A href = "#" id = "aSecond"> set the background color of the 2nd Divs. </a> |
<A href = "#" id = "aThird"> set the background color of the DIV except for the first DIV. </a> |
<A href = "#" id = "aFourthly"> set an element whose name attribute value starts with DIV </a> |
<A href = "#" id = "aFifthly"> set the element whose name attribute value ends with ly </a> |
<A href = "#" id = "aSixth"> set the elements whose name attribute value contains th </a> |
<A href = "#" id = "aSeventh"> comprehensive application </a>

</Body>
</Html>

1. $ ("selector [Attribute]") -- Note: [Attribute]
Description: gets the element set with Attribute in the element set selected by selector. It should be relatively simple. I will not elaborate on it here. I will post a post that I don't know.
Returned value: Array (Element );
2. [attribute = value]
Description: gets the element set with the Attribute Value equal to the Value in the element set selected by selector.
Returned value: Array (Element );
3. [attribute! = Value]
Description: gets the element set with Attribute values not equal to Value in the element set selected by selector.
Returned value: Array (Element );
4. [attribute ^ = value]
Description: gets the element set that has Attribute values starting with Value in the element set selected by selector. Equivalent to the regular expression ^
Returned value: Array (Element );
5. [attribute $ = value]
Description: gets the element set that has the Attribute Value ending with Value in the element set selected by selector. Equivalent to the regular expression ^
Returned value: Array (Element );
6. [attribute * = value]
Description: gets the element set with the Attribute Value containing the Value in the element set selected by selector.
Returned value: Array (Element );
7. [selector1] [selector2] [selectorN]
Description: similar to the integrated application of the basic selector in chapter 1, this method is the first six integrated editions, as in my example $ ("div [id] [name! = Incluthly] [name * = I] ") is to retrieve all the div elements, with the ID attribute & name attribute! = Fifthly & name is a set of DIV elements containing the character I. You can use my example to get a clear picture of the effect. This method should be useful ^
Returned value: Array (Element );

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.