2017-04-04 54 views
1

我在我的網站上使用延遲加載顯示圖像,它使用jQuery在顯示圖像之前是可見事件。此功能僅適用於Chrome版本57.Jquery .is(':visible')不能在頁面加載鉻版本57

+0

這是一個錯誤報告工作?如果是這樣:https://bugs.jquery.com。 –

+0

我不認爲這與谷歌瀏覽器有任何關係...你有沒有嘗試在其他瀏覽器? [www.whathaveyoutried.com](http://whathaveyoutried.com) – think123

+0

這可能是任何東西,從你的DOM上可以得到1皮秒以上,從jQuery的一個錯誤,緩存問題,錯誤的代碼,無效的HTML,CSS ,缺少'$(document).ready()'...我可以繼續多年!沒有顯示導致問題的一些代碼,我們什麼也不做,只能推測。 –

回答

0

jQuery.is(':visible')不適用於所有瀏覽器。

如果你要檢查你可以用下面的函數,將在所有的瀏覽器

jQuery.fn.extend({ 
    isvisible: function() { 
    // 
    // This function call this: $("div").isvisible() 
    // Return true if the element is visible 
    // Return false if the element is not visible for our eyes 
    // 
    if ($(this).css('display') == 'none'){ 
     console.log("this = " + "display:none"); 
     return false; 
    } 
    else if($(this).css('visibility') == 'hidden'){ 
     console.log("this = " + "visibility:hidden"); 
     return false; 
    } 
    else if($(this).css('opacity') == '0'){ 
     console.log("this = " + "opacity:0"); 
     return false; 
    } 
    else{ 
     console.log("this = " + "Is Visible"); 
     return true; 
    } 
    } 
});