【发布时间】:2011-03-17 20:43:46
【问题描述】:
我正在使用 .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 等——如果没有这些,同样的事情也会发生)。
有更好的方法吗?
【问题讨论】:
-
请发布您的标记和 jQuery 选择器。
-
请附加有问题的html代码和您使用的选择器
标签: jquery cross-browser selector