【为什么】这个Javascript代码哪里有问题啊,跪求大神解答~~~~~~
-------------------html页面---------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ajax</title>
</head>
<body>
<h1>What is the Document Object Model</h1>
<p>
the <abbr title="World Wide Web Consortium">W3C</abbr>defines the <abbr title="Document
Object Model">DOM</abbr> as;
</p>
<blockquote cite="http://www.w3.org/DOM/">
<p>
a platform and language-neytral interface that will allow programs and scripts to dynamically access
and update the content,structure and style of documents.
</p>
</blockquote>
<p>It is an <abbr title="Aplication Programming Interface">API</abbr>
that can be used navigate <abbr title="extensible Markup language">XML</abbr>documents.
</p>
<script src="addLoadEvent.js"></script>
<script src="displayAbbreviations.js"></script>
</body>
</html>
----------------------addLoadEvent.js页面--------------------------------
function addLoadEvent(func){
var oldload=window.onload;
if(typeof window.onload!='function'){
window.onload=func;
}else{
window.onload=function(){
oldload();
func();
}
}
}
------------------------displayAbbreviations.js页面-----------------------
function getabbr(){
var dll=document.createElement("dl");
var abbr1=document.getELementsByTagName("abbr");
for(var i=0;i<abbr1.length;i++){
var title1=abbr1[i].getAttribute("title");
var key=abbr1[i].lastChild.nodeValue;
var ddd=document.createElement("dd");
var dtt=document.createElement("dt");
var keyText=document.createTextNode(key);
var titleText=document.createTextNode(title1);
dtt.appendChild(keyText);
ddd.appendChild(titleText);
dll.appendChild(dtt);
dll.appendChild(ddd);
}
document.body.appendChild(dll);
}
addLoadEvent(getabbr);
----------------------------------------------
JS代码的目的是从HTML页面里面取出<abbr>标签的title值和其对应的文本内容。并且以
列表
<dl>
<dt>题目</dt>
<dd>内容</dd>
<dt>题目</dt>
<dd>内容</dd>
</dl>
的形式表现出来。但是代码运行后HTML页面没有变化,请问是代码有问题吗?
如果有问题,那问题在哪里?代码该如何改?
------解决方案--------------------
JScript code
function getabbr(){
var dll=document.createElement("dl");
//var abbr1=document.getELementsByTagName("abbr");//EL,是El,大写了
var abbr1=document.getElementsByTagName("abbr");
for(var i=0;i<abbr1.length;i++){
var title1=abbr1[i].getAttribute("title");
var key=abbr1[i].lastChild.nodeValue;
var ddd=document.createElement("dd");
var dtt=document.createElement("dt");
var keyText=document.createTextNode(key);
var titleText=document.createTextNode(title1);
dtt.appendChild(keyText);
ddd.appendChild(titleText);
dll.appendChild(dtt);
dll.appendChild(ddd);
}
document.body.appendChild(dll);
}
addLoadEvent(getabbr);