WEB开发网
开发学院网页设计JavaScript 分离式javascript,取当前element 阅读

分离式javascript,取当前element

 2010-09-14 13:18:17 来源:WEB开发网   
核心提示:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<htmlxmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>nodelist</title> 
</head> 
<body> 
<liclass="aa"id="0">0</li> 
<liclass="aa"id="1">1</li> 
<liclass="aa"id="2">2</li> 
<liclass="aa"id="3">3</li> 
<liclass="aa"id="4">4</li> 
<scriptlanguage="Javascript"> 
varelems=document.getElementsByTagName('li');  
for(vari=0;i<elems.length;i++)  
{  
  elems[i].i=i+1;  
  elems[i].onclick=function(){  
  alert(this.i+this.innerHTML);  
  }  
}  
</script> 
</body> 
</html>

Tags:分离式 javascript 当前

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接