1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 2 
 3 <HTML>
 4     <HEAD>
 5         <TITLE>removeNode() Example</TITLE>
 6         <META http-equiv=Content-Type content="text/html; charset=gb2312">
 7         <META content="MSHTML 6.00.2900.2963"  name=GENERATOR>
 8     </HEAD>
 9     <BODY text=#000000 vLink=#800080 aLink=#ff0000 link=#0000ff  bgColor=#99cccc>
10         <CENTER>
11             <H1>removeNode() Method</H1>
12         </CENTER>
13         <P>
14         <CENTER>
15 
16 <!--这个兼容ie和chrome-->
17             <BUTTON  onclick=this.parentNode.removeChild(this)>           
18 
19                 Remove This Button,but keep the test
20             </BUTTON> 
21         </CENTER>
22         <P>
23 <!--这个只能在ie下使用-->
24    <BUTTON onclick=this.removeNode(false)>
25 
26                 Remove This Button and remove text
27             </BUTTON>   
28             <BUTTON onclick=this.removeNode(true)>
29 
30                 Remove This Button and remove text
31             </BUTTON>         
32     </BODY>
33 </HTML>

说明:

    1、this.removeNode(false)

        表示将<BUTTON></BUTTON>标记删除,但保留"Remove This Button,but keep the test"文本,

        文本的地位上升至<CENTER></CENTER>节点的子节点。

    2、this.removeNode(true)

        表示将<BUTTON></BUTTON>标记以及在标记之间的内容全部删除。

相关文章: