闭包的应用

var ary = ["foo1","foo2","foo3"];

for (var i = 0, len = ary.length; i < len; i++) {
  setTimeout(function(){
    document.getElementById(ary[i]).style.display = "none";
  },0);
}
原文地址:https://www.cnblogs.com/rubylouvre/p/1665799.html