我正在使用 .eq() 方法来选择已知元素的特定子元素。 IE 和 Chrome/FF 中的元素索引似乎不同,因为 .eq(2) 根据浏览器返回不同的值。 (我正在寻找的元素在 FF/Chrome 中显示为 .eq(2),但在 IE 中显示为 .eq(3))
例如,
alert($(this).parent().children().eq(2).text());
根据浏览器显示不同的结果。
这是有问题的标记:
<div>
<span>
<input onclick="player.search.Groupings($(this).parent().children().eq(2).text(), $(this).parent().children().eq(0).is(':checked'));" type="checkbox"></input>
<span>Fake Initiative A</span><span>1</span>
</span>
<span>
<input onclick="player.search.Groupings($(this).parent().children().eq(2).text(), $(this).parent().children().eq(0).is(':checked'));" type="checkbox"></input>
<span>Initiative B Not Real</span><span>2</span> </span>
</div>
(我删除了属性、内联 css 等——如果没有这些属性,同样的事情也会发生)。
有更好的方法吗?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)