2013-07-16 20 views

回答

3
("*").filter(function() { 
    var zindex = $(this).css("z-index"); 
    return (zindex !== undefined) && zindex < 1; 
}).hide(); 
+0

@DavidThomas我不認爲z-index只能是數字。但是,我添加了一個「undefined」的檢查,以防一個元素根本沒有這個樣式。 – Barmar

+0

而'''會自動將它強制爲一個數字。 – Barmar

+0

(刪除了我以前的評論以減少噪音,我會馬上刪除。) –

2

我會做這種方式:

$('body *').css('display', function() { // don't hide the head/body/html tag 
    return this.style.zIndex > 0 ? this.style.display : 'none'; 
}); 
0

最簡單的方法是寫一個過濾功能。然後調用每個隱藏。

$("div").filter(function(){ 
    return $(this).css('z-index') <= 1; 
}).each(function(){ $(this).hide() });