- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>增加删除DIV的JS写法</title>
- </head>
-
- <body>
- <div id="main">
- <div id="box">111</div>
- <div class="box2">222</div>
- </div>
- <script type="text/javascript">
- var box = document.getElementById("box");
- var main = document.getElementById("main");
- var newMask = document.createElement("div");
- newMask.id ="newMask";
- main.appendChild(newMask);
- if(box){
- box.parentNode.removeChild(box);
- }
- else{
- alert("没有这个div");
- }
- </script>
- </body>
- </html>
- <div id="main">
- <div id="box">111</div>
- <div class="box2">222</div>
- </div>
- <script type="text/javascript">
- var box = document.getElementById("box");
- box.parentNode.removeChild(box);
- </script>
-
相关文章:
-
2022-12-23
-
2021-06-22
-
2022-03-01
-
2022-12-23
-
2022-12-23
-
2021-12-09
猜你喜欢
-
2022-12-23
-
2021-08-26
-
2021-12-31
-
2022-12-23
-
2022-12-23
-
2021-12-26
相关资源
-
下载
2021-06-05
-
下载
2021-06-05
-
下载
2022-12-28