Yes of course, silly me, I did not spot that, your second update is correct!
.get(0) (or just [0] for short) returns the actual dom element instead of
a jqueryised element.
So any one of these should work for you:
- $("#my li").eq(2).text()
- $("#my li:eq(2)").text()
- $($("#my li")[2]).text()
As it happens, I have a thread running on
http://www.nabble.com/Correct-way-to-get-the-nth-item--tf2694862.html#a7515463
this very topic . Doh!
George
Alexey Grischenko wrote:
>
> George, thank you for your help but
> I run my $("#my li").get(2).text()
> after all loaded.
>
> I use it in one "callback" function when i have to change some data on
> page after some user actions...
>
> so if i try something like
>
> alert ($("#my li").get(2)) - i see correct alert "HTMLLiobject" but
> when i try
> alert ($("#my li").get(2).text()) or alert ($("#my li").get(2).html())
> i see just javascript error like "text is not function"....
>
>
> UPDATE NUMBER TWO :)
>
> Searching save the world :))))
>
> I think i found solution in
> http://www.nabble.com/Get-attribute-form-%24%28%29-tf2336155.html#a6500007
> this topic
>
> If i understand it correct, Jquery $(...).get(..) return real DOM object
> but not Jquery object. Of course in this case I can't use some Jquery
> methods right to DOM object.
>
>
> Is it true guys? :)
>
> John..... where are you... tell me true... :)))
>
> PS Sorry, I just in really funny mood this morning :)
>
>
>
>
--
View this message in context:
http://www.nabble.com/Need-help-with-get%28%29-tf2693047.html#a7519660
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/