关闭后的动态变量

时间:2017-06-24 14:47:18

标签: javascript closures

我有以下代码:

element.onclick=function(e){
    console.log(e.target.value);
};

我想这样做:

for(k in array)
    element.onclick=function(e,array_value){
        console.log(e.target.value,array_value);
    }(e,array[k]);

但是,我希望e保留对window.event对象的访问权限,而不必明确依赖window.event。从本质上讲,我希望通过事件监听器的第一个参数传递的任何内容都保持不变。

这可能吗?

0 个答案:

没有答案