<div class="htmlarea"> <textarea id="runcode69724"> <title> node list 脚本之家 www.jb51.net 分离式js</title> <li class="aa" id="0">0</li> <li class="aa" id="1">1</li> <li class="aa" id="2">2</li> <li class="aa" id="3">3</li> <li class="aa" id="4">4</li> <script language="Javascript"> var elems=document.getElementsByTagName('li'); for (var i=0;i<elems.length ; i++ ) { elems[i].i=i+1; elems[i].onclick=function() { alert(this.i+this.innerHTML); } } </script> </textarea><br><input onclick="runEx('runcode69724')" type="button" value="运行代码"> <input onclick="doCopy('runcode69724')" type="button" value="复制代码"> <input onclick="doSave(runcode69724)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>