1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>增加删除DIV的JS写法</title>
  6. </head>
  7. <body>
  8. <div id="main">
  9. <div id="box">111</div>
  10. <div class="box2">222</div>
  11. </div>
  12. <script type="text/javascript">
  13. var box = document.getElementById("box");
  14. var main = document.getElementById("main");
  15. var newMask = document.createElement("div");
  16. newMask.id ="newMask";
  17. main.appendChild(newMask);
  18. if(box){
  19. box.parentNode.removeChild(box);
  20. }
  21. else{
  22. alert("没有这个div");
  23. }
  24. </script>
  25. </body>
  26. </html>
  1. <div id="main">
  2. <div id="box">111</div>
  3. <div class="box2">222</div>
  4. </div>
  5. <script type="text/javascript">
  6. var box = document.getElementById("box");
  7. box.parentNode.removeChild(box);
  8. </script>

最新文章

  1. How to configure security of ActiveMQ ?
  2. 关于eclipse保存代码很慢,提示the user operation is waiting的问题
  3. Android 学习笔记 Service
  4. 关押罪犯(codevs 1069)
  5. 第一个简单的android项目
  6. 我学C的那些年[ch01]:浅淡C语言的编译过程
  7. SANSA 上上洛可可 贾伟作品 高山流水 香炉 香插香台香具 高端商务礼品 黑色【正品 价格 图片 折扣 评论】_尚品网ShangPin.com
  8. POJ1008 1013 1207 2105 2499(全部水题)
  9. Android Application Fundamentals——Android应用程序基础知识
  10. 【leetcode82】Linked List Cycle
  11. Java 程序员必须了解的 7 个性能指标
  12. 『TensorFlow』命令行参数解析
  13. 老菜鸟学习:Javascript 将html转成pdf
  14. Dreamweaver 2
  15. 【bzoj5118】Fib数列2 费马小定理+矩阵乘法
  16. c# XML读取
  17. iOS中的多线程 NSOperation
  18. perl学习(二)正则表达式
  19. mysql 触发器 trigger用法 three (稍微复杂的)
  20. curl基于URL的文件传输工具

热门文章

  1. C#基础视频教程2 常见数据类型和属性方法
  2. Jquery重新学习之二[属性attr(),removeAttr(),prop(),removeProp()]
  3. vim 查找和替换命令 替换/n和\n
  4. Creating a Fragment: constructor vs newInstance()
  5. jquery remove()不兼容问题解决方案
  6. Centos 开启telnet-service服务
  7. Linux命令-权限管理命令:chmod
  8. idea 更换编辑器背景图片
  9. Windows7清除图标缓存
  10. express 设置header解决跨域问题