jquery children selector issue
Hi I have shared the code here : http://jsfiddle.net/jTAZ4/
Why am i getting the length as 0 although I can see an li with the specified class. any help is deeply appr开发者_如何学Goeciated.
I know this will work with find but just wondering why children selector doesn't work.
That's because the <li>
is not a direct children of that <div>
.
You should use .find()
instead of .children()
.
.children()
only selects direct children. Try .find()
instead.
Try using .find('.jstree-leaf')
instead of .children('.jstree-leaf')
.
You have to use .find()
instead of .children()
alert($('div.round').find('.jstree-leaf').length);
.children()
only searches one level deeper and skips all the elements in deeper levels.
精彩评论