每次点击都会为索引添加1

时间:2011-11-04 13:50:22

标签: javascript jquery raphael

我正在尝试这样做,所以它在每次点击时为z索引添加1,所以它就像101,102,103 ......

st[0].onclick = function () {

        var z = 100;
        document.getElementById(current).style.display = "block";
        document.getElementById(current).style.zIndex = z++;
        current = state;
    };

1 个答案:

答案 0 :(得分:0)

将你的z移到你的功能之外。

var z = 100;

st[0].onclick = function () {
        document.getElementById(current).style.display = "block";
        document.getElementById(current).style.zIndex = z++;
        current = state;
    };