小编Dav*_*ldo的帖子

使用jQuery更改重叠图像z-index

我有三个矩形图像重叠在一条对角线内,第一个在左上角完全可见,第二个在中央部分隐藏在第一个,最后一个在右下角部分隐藏在第二个.我想要点击的图像在其他图像之上.我试图通过使用jQuery操纵z-index来实现这一点,但它似乎不起作用.实际上看起来jQuery甚至都没有得到认可.

这是我的测试代码:

<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js">
    $(document).ready(function () {
        $('#launch').click(function () {
            alert('Ok');
        });

        $('.bottom-pic').click(function () {
            $(this).css('z-index' : '1');
            $('.bottom-pic').not(this).css('z-index' : '0');
        });
    });
    </script>
    <style type="text/css">
    #pictures {
        width: 650px;
        height: 300px;

        margin-left: auto;
        margin-right: auto;
        margin-top: 20px;
        margin-bottom: 50px;

        position: relative;
    }

    #top {
        top: 0;
        left: 0;

        position: absolute; 
        z-index: 1;
    }

    #center {
        top: 60px; 
        left: 200px;

        position: absolute; 
        z-index: 1;
    }

    #bottom {
        top: 150px; 
        left: 400px; 

        position: absolute; 
        z-index: 0;
    }
    </style> …
Run Code Online (Sandbox Code Playgroud)

html css jquery z-index

6
推荐指数
1
解决办法
2621
查看次数

标签 统计

css ×1

html ×1

jquery ×1

z-index ×1