我有以下 DOM 结构:
<div id="cont">
<ul>
<li>
<span class="c1"><span class="c2">...</span><span class="c3">...</span></span>
</li>
<li>
<span class="c1"><span class="c2">...</span><span class="c3">...</span></span>
</li>
<li>
<span class="c1"><span class="c2">...</span><span class="c3">...</span></span>
</li>
...
<li>
<span class="c1"><span class="c2">...</span><span class="c3">...</span></span>
</li>
</ul>
</div>
使用以下 jQuery:
$("#cont ul li").each(function (e) {
$(this).bind("mousemove",function(d) {
var ele = $(this + " .c2");
var ele2 = $(this " .c3");
//do stuff
});
});
我想做的是访问相对于当前 dom 位置的“c2”和“c3”元素。我希望循环选择相对于 DOM 顶部的以下内容:
ele = $("#cont ul li span .c2");
ele = $("#cont ul li span .c3");
//Do Stuff
//Move to the next set of Li's
ele = $("#cont ul li span .c2");
ele = $("#cont ul li span .c3");
//Do Stuff
//Move to the next set of Li's
ele = $("#cont ul li span .c2");
ele = $("#cont ul li span .c3");
//Do Stuff
//Move to the next set of Li's
..