Talking about those selectors

Source: Internet
Author: User
Jquery selector... hierarchical Selector
<! -- When you click the H2 element, add a color background of # 09f to the <span> element under # menu --> <! -- <SCRIPT type = "text/JavaScript"> $ (function () {$ ('h2 '). click (function () {$ ('# menu span'background .css ('background-color',' # 09f') ;}); </SCRIPT> -->
Basic Selector
<! -- Add a style for the tag selector --> <SCRIPT type = "text/JavaScript" >$ (function () {$ ('h2 '). click (function () {response ('h3'background .css ('background-color', '# 09f') ;}); </SCRIPT>
Basic filter Selector

 

<SCRIPT type = "text/JavaScript"> $ (function () {$ ('h2 '). click (function () {// $ ('li: first'background .css ('background-color', '# 09f'); // The first one // $ ('li: last'background .css ('background-color', '# 09f'); // The Last One // $ ('li: not(.three+'background .css ('background-color',' # 09f '); // elements whose class is not three // $ ('li: even'background .css ('background-color', '# 09f '); // element with an even index value // $ ('li: eq(1'' background .css ('background-color', '# 09f '); // element whose index value is 1 // $ ('li: gt(1'' background .css ('background-color', '# 09f '); // element with an index value greater than 1 // $ ('li: lt(1'' background .css ('background-color', '# 09f '); // element whose index value is less than 1 // $ (': header'background .css ('background-color',' # 09f'); // element of all titles $ (': focus'background .css ('background-color', '# 09f'); // elements that obtain the focus}) ;}</SCRIPT>
Visibility filter Selector
<SCRIPT src = "JS/jquery-1.8.3.js"> </SCRIPT> <SCRIPT type = "text/JavaScript"> $ (function () {// $ ('P: den den '). show (); // display text $ ('P: visable '). hide (); // hide text}); </SCRIPT> <style type = "text/CSS"> # txt_show {display: none; color: # 00c ;} # txt_hide {display: block; color: # f30 ;}</style> Attribute Selector
<! -- Change the value of the class attribute to the background color of the odds element --> <SCRIPT type = "text/JavaScript" >$ (function () {$ ("h2 "). click (function () {$ ("[class = odds]" ground .css ("background-color", "# ffffff") ;}); </SCRIPT>

 

Talking about those selectors

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.