var aLi = document.querySelectorAll('.article-tab li'); for (var i = 0; i <= aLi.length; i++) { (function(){ var p = i aLi[i].onclick = function() { a ...
var aLi = document.querySelectorAll('.article-tab li');
for (var i = 0; i <= aLi.length; i++) {
(function(){
var p = i
aLi[i].onclick = function() {
alert(p);
}
})();
}