Since you're using jQuery, it's worth noting that this
is already maintained by jQuery itself:
$("li").each(function(j,o){
$("span", o).each(function(x,y){
alert(o + " " + y);
});
});
In this example, o
represents the li
, whereas y
represents the child span
. And with $.click()
, you can get the scope from the event
object:
$("li").click(function(e){
$("span", this).each(function(i,o){
alert(e.target + " " + o);
});
});
Where e.target
represents the li
, and o
represents the child span
.