Jquery CSS selector DEMO code

Source: Internet
Author: User

Effect:

Core code: CopyCode The Code is as follows: <SCRIPT type = "text/JavaScript">
Certificate ('{one'}.css ("background", "# fff ");
Certificate ('div'0000.css ("background", "# fff ");
$ ('Body div'hangzhou.css ("background", "# bbffaa"); // you can change the attributes of all the divs in the body.
$ ('Div> span'background .css ("background", "# bbffaa" ).css ("color", "Red" ).css ("font-size", "12px "); // change the attribute of the span element under all Div
$ ('# Two> .mini').css ("background", "Red"); // all the classes in the DIV whose ID is two are attributes of mini Elements
$ ('# Two'). siblings ("Div" ).css ("color", "green"); // select the # two peer Div element, regardless of the front and back positions
$ ('Div: first'background .css ("background", "Red ");
$ ('Div: gt(1'hangzhou.css ("background", "# fff"); // All DIV elements whose index value is greater than 1
$ ('Div: lt(1'' background .css ("background", "yellow ");
$ ('Div: not(.one+'0000.css ("color", "# cccccc"); // change the DIV element whose class is not one.
$ ('Div: even'0000.css ("font-size", "15px"); // Div with an even Index Number
$ ('Div: odd'0000.css ("font-size", "12px"); // Div with an odd Index Number
$ ('Div: contains(otherw.'hangzhou.css ("font-size", "10px"); // you can specify the DIV element containing the text other.
$ ('Div: has(.mini}'}.css ("color", "# bbffaa"); // you can specify the background color of the <div> element containing the class as the mini element.
$ ('Div: parent'0000.css ("color", "# ffcccc"); // you can change the attributes of a div element containing child elements (including text ).
$ ('Div: Den den '). Show (3000); // obtain the hidden Div
$ ('Div: visable') // obtain the visible Div
$ ("Div [Title = test]" ).css ("background", "black"); // sets the DIV whose title is test.
$ ("Div [. Mini] [Title = test]" ).css ("color", "Red"); // sets the DIV whose class is Mini title and test.
</SCRIPT>

Full DEMO code:Xmlns = "http://www.w3.org/1999/xhtml">


ID: One Class: One

Class: miniclass: Mini, Title: otherclass: Mini, Title: testclass for Mini, title for test

The span under DivStyle for display none's Div

Related Article

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.