<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>删除子节点removeChild()</title> <!-- node.removeChild(a);删除父节点node下的子节点a --> </head> <body> <div> 我是div <p>我是p</p> </div> <script> var div=document.getElementsByTagName("div")[0];//获取父节点div var p=document.getElementsByTagName("p")[0];//获取子节点p div.removeChild(p);//删除子节点p </script> </body> </html>