可能重複:
jquery .is(「:visible」) not working in ChromejQuery的。是( 「:可見」)在Firefox而不是Chrome瀏覽器
我試圖讓所有可見的項目在數組中。它在Firefox中運行良好,但不是Chrome。
這裏是我的代碼:
$.each (t.config.promoInput, function (i, v) {
var size = 0;
$.each ($(v).find('option'), function (i, v) {
$(v).show() // Show all options in <tt>$(v)</tt>.
.not(':first-child') // Don't hide <tt>(All)</tt>.
.not(':Contains("' + t.config.searchSpanInput.val() + '")') // Don't hide options that match the searchCriteria.
.hide(); // Hide everthing that doesn't match or isn't (All).
if ($(v).is(":visible")) {
size++;
}
});
});
在Firefox大小的增量,而Chrome的大小保持等於0
編輯::包含是我自己除了jQuery庫。它是一個不區分大小寫的:contains的版本。
HTML的外觀如何? – Pointy 2012-02-02 15:44:23
請注意,你必須關閉'每個'代碼塊 – 2012-02-02 15:46:18
另外,我不確定,但我認爲引用嵌套函數中的i和v將訪問父範圍中的那些,所以不需要傳遞它們? – 2012-02-02 15:47:24