I have this:
- first
- second
- third
- fourth
I would try:
$("ul li:nth-child(2)")
The get
method returns the DOM element, so then you would have to wrap it inside a new jQuery object.
You can use the eq
method:
var j = $('ul li').eq(1); // gets the second list item
Use :eq() Selector. For for example, for second element use:
$("ul li:eq(1)");
you can use nth-child
$("ul li:nth-child(2)") //this will select second child because it is 1 based index
here is a fiddle http://jsfiddle.net/xyyWh/
$('li').get(0) will return plain DOM element. you cannot call jQuery methods on same.