javascrip 之DOM操作

来源:互联网 发布:链接数据库接口 编辑:程序博客网 时间:2024/06/05 05:42

                   准备工作:

     
<html>
<head>
  <title>JavaScript and the Document Object Model</title>
</head>
<body>
  <div id="page">
    <div id="header"><h1 id="title">Page title</h1></div>
    <div id="content">
      <h2>Content title</h2>
      <p>Some copy goes here</p>
      <p>More copy goes here</p>
    </div>
  </div>
</body>
</html>

  1.使用以下属性,可以获得文档的节点:

 firstChild
 lastChild
nextSibling 
previousSibling 
parentNode .
childNodes

 

   2.使用以下属性,可以用来操作节点的值

nodeValue.

  3.使用以下属性,可以用来增加,删除,替换文档中的节点

appendChild method 
 insertBefore method 
 removeChild method
replaceChild method

 

 

  

 

 

原创粉丝点击