js---html dom

1:<p id="id1">abc</p>

var x=document.getElementById("id1");

document.write("<p>note是:"+x.innerHTML+"</p>");

在上面的3行代码中,getElementById 是一个方法,而 innerHTML 是属性。

innerHTML 属性可用于获取或改变任意 HTML 元素,包括 <html> 和 <body>。

还有类似方法:

2:nodeValue:属性规定节点的值

nodeName:属性规定节点的名称,是只读的。

<p id="intro">Hello World!</p>

x=document.getElementById("intro");
document.write(x.firstChild.nodeValue);

3:除此之外,还有很多

posted @ 2013-11-13 10:48  歌颂者  阅读(119)  评论(0编辑  收藏  举报