Possible Duplicate:
How to get nth jQuery element
Get an element by index in jquery
What is the jQuery equivalent of the square brackets [ ] indexing notation for selecting the Nth item from an array?
Say you have 10 paragraphs and want to get the contents of the 7th one. Using square bracket notation works, but not if you want to keep using jQuery:
$("p")[6]; //returns DOM object: [object HTMLParagraphElement]
$("p")[6].html(); //returns error: (Chrome:) Uncaught TypeError: Object #<HTMLParagraphElement> has no method 'html' (Firefox:) TypeError: $("p")[6].html is not a function (IE8+:) TypeError: Object doesn't support this property or method (IE7:) [object Error]
Square bracket [n] index notation works but you get the native Javascript DOM object, not something that jQuery can work with. Use jQuery’s
.eq()method or the:eq()selector to get a jQuery object.(jsfiddle example)