我試圖編寫一個jQuery滑塊。我有一個html代碼,看起來像這樣。我早些時候發佈了一個更簡單的代碼版本,以便這個問題看起來不會太長。對帶來的麻煩表示抱歉。下面是實際的代碼Jquery.find()在ie中返回null,但在其他瀏覽器中不返回
<div class="allItems">
<div class="echItm">
<h4>asdddddddd </h4>
<span class="mImg">/web/images/promotionSlideShowImages/kc1g358wvv.jpg</span>
<span class="tImg">/web/images/promotionSlideShowThumbnailsNew/kc1g358wvv.gif</span>
</div>
<div class="echItm">
<h4>dddddddddd </h4>
<span class="mImg">/web/images/promotionSlideShowImages/ptvrbfpnkd.jpg</span>
<span class="tImg">/web/images/promotionSlideShowThumbnailsNew/ptvrbfpnkd.gif</span>
</div>
</div>
當我嘗試使用
var imagesArray=$('.allItems').find('.echItm');
for(var i=0;i<imagesArray.length;i++){
var thisElement=imagesArray[i];
alert($(thisElement).html());
}
IE返回null,而火狐,Chrome返回所需的HTML做一個查找。有人能指導我,我做錯了什麼?我正在使用Jquery 1.4.2並在IE8上進行測試。提前致謝。
好像有可能是這裏的解決方案: http://stackoverflow.com/questions/562283/jquery-find-doesnt-return-data-in-ie-but-does-in-firefox -and-chrome –
您使用的是哪個IE版本?我已經[在IE7上運行你的代碼](http://jsfiddle.net/7DLex/)沒有問題。 – OnesimusUnbound
看起來這可能是相同的問題: http://stackoverflow.com/questions/562283/jquery-find-doesnt-return-data-in-ie-but-does-in-firefox-and -chrome –