我正在使用.eq()方法來選擇已知元素的特定子元素。 IE和Chrome/FF中的元素索引看起來不同,因爲.eq(2)根據瀏覽器返回不同的值。 (我在尋找顯示爲.EQ(2)在FF /鉻,但.EQ(3)在IE元素)jQuery .eq(x)返回IE中的不同元素比FF/Chrome中的
例如,
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選擇。 – cletus 2010-03-09 07:33:55
請附上有問題的HTML代碼和您使用的選擇器 – jitter 2010-03-09 08:37:33
添加標記,thx – btk 2010-03-09 22:54:39