I have this reqular ul > li structure
<ul class='compare'>
<li>Level 1
<ul>
<li>Level 2</li>
<li>Level 2</li>
<li>Level 2</li>
<li>Level 2</li>
</ul>
</li>
<li>Level 1
<ul>
<li>Level 2</li>
<li>Level 2</li>
<li>Level 2</li>
<li>Level 2</li>
</ul>
</li>
<li>Level 1
<ul>
<li>Level 2</li>
<li>Level 2</li>
<li>Level 2</li>
<li>Level 2</li>
</ul>
</li>
</ul>
I use $("ul.compare > li").live(...); to assign mouse events to children of ul
But now I need to get children of an object. Let say obj is my $("ul.compare")
If I do like this $("li", obj).live(...) this assigns event to all li not only children.
I can do in this way but I don’t like it
obj.children("li").each(function () {
$(this).live(...);
});
Is there a way to select all children of an object and apply live directly without using .each()?
Thanks @Matt, it seems you answered my question with your comment unwittingly. Solution is
.on()While this is not working, and we have to use
.each()to assignmouseoverto every matched elementthis works and there is no need
.each()