In jQuery, $("...").get(3)
returns the 3rd DOM element. What is the function to return the 3rd jQuery element?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Why not browse the (short) selectors page first?
Here it is: the
:eq()
operator. It is used just likeget()
, but it returns the jQuery object.Or you can use
.eq()
function too.if you have control over the query which builds the jQuery object, use
:eq()
If you don't have control over it (for example, it's being passed from another function or something), then use
.eq()
Or if you want a section of them (say, the third, fourth and fifth elements), use
.slice()
I think you can use this
It finds the second li in each matched ul and notes it.
Live Example to access and remove the Nth element with jQuery:
When it runs, there are two items in the ordered list that show, First, and Third. The second was hidden.
You can use the :eq selector, for example:
Or the Traversing/eq function:
Also, remember that the indexes are zero-based.