我试图简单地检测是否单击了我班的任何实例;如果是这样,就隐藏div。
var classname = document.getElementsByClassName("big-button");
for (var i = 0; i < classname.length; i++) {
classname[i].addEventListener('click', myFunction, false);
document.getElementById('hidethisDiv').style.display = "none";
}
答案 0 :(得分:1)
您需要将此代码auto show_fn = CLASS_MEMBER(A, show);
show_fn(a, 1); // ok, calls a.show(1)
show_fn(a, 1, 2); // ok, calls a.show(1, 2)
show_fn(a, 1, 2, 3); // error, no matching call - but sfinae friendly
放在函数中。
document.getElementById('hidethisDiv').style.display = "none"
var classname = document.getElementsByClassName("big-button");
function myFunction() {
document.getElementById('hidethisDiv').style.display = "none";
}
for (var i = 0; i < classname.length; i++) {
classname[i].addEventListener('click', myFunction, false);
}