jquery - How to access child element out of children()? -
I want to get an element of children instantly, and then want to get a particular class of a child index . Something like this:
var index = 25; Var children = $ ("# myListElement"). Children (); If (index; lt; children.length) {if (children [index] .hasClass ("testclass")) {Warning ("Hello!");
I think that. Syntax () is fine, but how do I get them into indexed elements in jQuery style?
Thanks
children
method one Array-like object that includes plain dome nodes, you can wrap it to an inherent element with jQuery, or by using the eq (index)
method on it hasClass < / Code> should be able to use jQuery methods.
If ($ (children [index]). Haclas ("Test class"))
jQuery does not wrap them by default for obvious performance reasons Does
If you are using a firebug or Chrome / WebKit developer tool, you will get an exception when you try to call an undefined method on an object. See . Make sure you are viewing the console output :)
TypeError: object # & lt; An HTMLLIElement & gt; There is no way 'hackass'
Comments
Post a Comment