小剑灬
2016-04-13 16:03
<!DOCTYPE HTML> <html> <head id="txt" name="head1"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>节点属性</title> </head> <body> <ul> <li>javascript</li> <li>HTML/CSS</li> <li>jQuery</li> </ul> <script type="text/javascript"> var h = document.getElementById("txt"); // document.write(h.nodeValue); var k = h.getAttribute("name"); document.write(k.nodeValue+" "+k.nodeType+" "+k.nodeName); </script> </body> </html>
document.write(k.nodeValue+" "+k.nodeType+" "+k.nodeName);
这句你把k换成h试试
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题