@H_502_0@废话不多说了,直接给大家贴代码了,具体代码如下所述:
<div class="jb51code">
<pre class="brush:js;">
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);
}
})();
}