<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<script>
var w=100;
function a(){
var w=5;
return function(){
console.log(this);
alert(w);
}
}
var c=a();
c();
alert(w);
var spans=document.getElementsByTagName("span");
for(var i=0;i<spans.length;i++){
/*(function(t){
spans[t].οnclick=function(){
alert(t);
}
})(i);*/
spans[i].οnclick=(function(t){
return function(){
alert(t);
}
})(i);
}
</script>
</body>
</html>