<html lang="en"><head>
<meta charset="UTF-8">
<title>Title</title></head><body><ul id="box">
<li>xx</li>
<li>aa</li>
<li>dd</li>
<li>ss</li></ul><script>
var box = document.getElementById("box"); var liObj = box.children; for (var i = 0; i < liObj.length; i++) { var li = liObj[i];
(function (i) {
li.onclick = function () { console.log(i)
};
})(i)
}**加粗文字**</script></body></html>
添加回答
举报
0/150
提交
取消