• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

老王的蜕变

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

js 兼容removeNode方法

 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>标记以及在标记之间的内容全部删除。

posted on 2013-04-17 14:57  老王的蜕变  阅读(1372)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3