2010-09-08 73 views

回答

3

那是因为<li>不是那个<div>的直接子女。

You should use .find()而不是.children()

+0

好吧,我知道我不得不使用查找,但我知道.children刚刚搜索元素单层下来 – Baz1nga 2010-09-09 10:23:48

0

尝试使用.find('.jstree-leaf')而不是.children('.jstree-leaf')

0

你必须使用.find()代替.children()

alert($('div.round').find('.jstree-leaf').length); 

.children()只搜索一个更深层次的原因跳过更深层次的所有元素。