0

我试图编写一个 jquery 代码来隐藏 z-index 小于 1 的所有元素。我一点也不知道从哪里开始。

4

3 回答 3

3
("*").filter(function() {
    var zindex = $(this).css("z-index");
    return (zindex !== undefined) && zindex < 1;
}).hide();
于 2013-07-16T05:20:45.660 回答
2

我会这样做:

$('body *').css('display', function() { // don't hide the head / body / html tag
    return this.style.zIndex > 0 ? this.style.display : 'none';
});
于 2013-07-16T05:33:10.297 回答
0

最简单的方法是编写一个过滤函数。然后对每个调用隐藏。

$("div").filter(function(){
    return $(this).css('z-index') <= 1;
}).each(function(){ $(this).hide() });
于 2013-07-16T05:45:32.983 回答