Page 1 of 1

Select 2nd element of UL

Posted: Wed Apr 13, 2011 2:29 am
by dheeraja
Hello Guys,
I am using Jquery to show or hide element of <ul> with the following code:

Code: Select all

$('#menu ul:first').show();
or

Code: Select all

$('#menu ul:last').show();
but this will help me with only first & last element, if I want to do this with 2nd or 3rd then what I have to do??
Please help me..

Thanks in advance...

Re: Select 2nd element of UL

Posted: Wed Apr 13, 2011 9:51 am
by pickle
The "eq" selector is what you want: http://api.jquery.com/eq-selector/

Code: Select all

$('#menu ul li:eq(1)').show()