<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.jb200.com/" />
<title>
脚本学堂_www.jb200.com</title>
<style type="text/css">
ul{
list-style:none;
width:100px;
height:25px;
line-height:25px;
font-size:12px;
}
</style>
<script type="text/
javascript">
window.onload=function(){
var obox=document.getElementById("box");
var oshow=document.getElementById("show");
var lis=obox.getElementsByTagName("li");
for(var index=0;index<lis.length;index++){
lis[index].theIndex=index;
lis[index].onclick=function(){
oshow.innerHTML=this.theIndex;
}
}
}
</script>
</head>
<body>
<div>当前元素的顺序:<span id="show"></span></div>
<ul id="box">
<li>脚本学堂一</li>
<li>脚本学堂二</li>
<li>脚本学堂三</li>
<li>脚本学堂四</li>
<li>脚本学堂五</li>
<li>脚本学堂六</li>
</ul>
</body>
</html>