Discuz教程网

JS删除特定DIV

[复制链接]
authicon 星火燎原 发表于 2011-5-21 22:40:54 | 显示全部楼层 |阅读模式
使用removeChild来移除元素

Js代码
  1. <html>   
  2. <body>   
  3. <div id="d" style="color:red;">112</div>   
  4. <body>   
  5. <script>   
  6. var obj = document.getElementById("d");   
  7. document.body.removeChild(obj);   
  8. </script>   
  9. </html>  
复制代码
顺便说一下,若想隐藏DIV

Js代码
  1. <div di='qq'>adsf</div>   
  2. <scrtip>   
  3.       document.all.qq.style.display='none';   
  4. </script>  
复制代码




上一篇:JS动态创建元素
下一篇:使用CSS固定漂浮导航栏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-6-17 10:48

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表