jquery: GT Selector

Source: Internet
Author: User

: Definition and usage of GT selector:

This selector matches all elements that have an index value greater than the given index value.

The minimum index value starts at 0.

Syntax structure:

$ (": GT (Index)")

This selector is typically used in conjunction with other selectors, such as class selectors and element selectors, and so on. For example:

$ ("li:gt (0)"). CSS ("Color", "blue")

The above code can set the font color in the LI element with an index greater than 0 to green.

If not used with other selectors, the default state is used with the * selector, such as $ (": GT") equivalent to $ ("*:GT").

Parameter list:

Parameters Describe
Index The given index value

Instance code:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){   $("#btn"). Click (function(){     $("li:gt (0)"). CSS ("Color","Blue"); })})</Script></Head><Body><ul>  <Li>HTML area</Li>  <Li>Div+css Zone</Li>  <Li>jquery Zone</Li>  <Li>JavaScript zone</Li></ul><ButtonID= "BTN">Click to view Effects</Button></Body></HTML>

The above code sets the color of the font in the LI element's collection of LI elements with an index value greater than 0 to blue.

Example two:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){   $("#btn"). Click (function(){     $(": GT (1)"). CSS ("Color","Blue"); }); }); </Script></Head><Body><ul>  <Li>HTML area</Li>  <Li>Div+css Zone</Li>  <Li>jquery Zone</Li>  <Li>JavaScript zone</Li></ul><ButtonID= "BTN">Click to view Effects</Button></Body></HTML>

Since the code above does not specify a selector that is used with the GT selector, it is used with the default and the * selector, so the above code can set the font color in the element with the index value greater than 1 in all elements in the current document to blue.

The original address is: http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4200.html

The most original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=5362

jquery: GT Selector

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.