The example in this article covers jquery: the GT selector usage. Share to everyone for your reference. The specific analysis is as follows:
This selector matches all elements that have index values greater than the given index value.
The minimum index value starts at 0.
Syntax structure:
Copy Code code as follows:
This selector is typically used in conjunction with other selectors, such as the class selector and the element selector, and so on. For example:
Copy Code code as follows:
$ ("li:gt (0)"). CSS ("Color", "blue")
The above code sets the font color to green in the LI element with an index greater than 0.
If you do not use it with other selectors, the default state is to use with the * selector, for example $ (": GT") equals $ ("*:gt").
Parameter list:
Parameters |
Describe |
Index |
The given index value |
Instance code:
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" content= "http://www.jb51.net/"/>
<title> Cloud-dwelling community </title>
<script type= "Text/javascript" src= "Mytest/jquery/jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#btn"). Click (function () {
$ ("li:gt (0)"). CSS ("Color", "blue");
})
})
</script>
<body>
<ul>
<li>html Zone </li>
<li>div+css Zone </li>
<li>jquery Zone </li>
<li>javascript Zone </li>
</ul>
<button id= "BTN" > Click to view Effect </button>
</body>
The above code sets the font color to blue in the LI element with an index value greater than 0 in the Li element collection.
Example two:
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" content= "http://www.jb51.net/"/>
<title> Cloud-dwelling community </title>
<script type= "Text/javascript" src= "Mytest/jquery/jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#btn"). Click (function () {
$ (": GT (1)"). CSS ("Color", "blue");
});
});
</script>
<body>
<ul>
<li>html Zone </li>
<li>div+css Zone </li>
<li>jquery Zone </li>
<li>javascript Zone </li>
</ul>
<button id= "BTN" > Click to view Effect </button>
</body>
Since the above code does not specify a selector to be used in conjunction with the: GT selector, the default and * selector are used, so the above code can set the font color to blue in all elements of the current document that have an index value greater than 1.
I hope this article will help you with your jquery programming.