: 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