<div id="box"> <p> <span>A</span> <span>B</span> </p> <div id="box2"> <span id="span3">C</span> <span id="span4">D</span> <span>E</span> </div> </div>
弹出
<span id="span4">D</span>在所有span中的所因为3
alert($("#box span").index($('#span4')));
弹出
<span id="span3">C</span>在box2中的索引为0
alert($("#box2 span").index($("#span3")));