I'd like to use the id selector:
$("#id")
Is there a way to do this to only the nth element with that ID on the page? i.e.
$("#id:n")
I'd like to use the id selector:
$("#id")
Is there a way to do this to only the nth element with that ID on the page? i.e.
$("#id:n")
You can use the
:eq(n)
selector fetch the n-th item, but id should be unique.You should use the
class
attribute to group similar elements.There can be only ONE element with a given id in a page.
From the HTML norm :
Now suppose you want to get the nth element with a given class in your page, you may use eq :
You can do like this:
But like @dystroy answer, it should be only 1 id in a page so you better using class.