The code example is as follows: <! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" content= "http://www.51texiao.cn/"/>
<title> Ant Tribe </title>
<style type= "Text/css" >
#father
{
width:150px;
height:150px;
background-color:red;
}
#father Div
{
width:50px;
height:50px;
Background-color:green;
font-size:12px;
}
</style>
<script type= "Text/javascript" src= "Http://www.softwhy.com/mytest/jQuery/jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#father"). Prepend ("<div> Ant tribe Welcome </div>");
})
</script>
<body>
<div id= "Father" ></div>
</body>
The above code can add a div to the parent div;
Here's a look at how to delete a div, just the core code:
$ (document). Ready (function() {
$ ("#father"). Prepend ("<div> Ant tribe Welcome </div>");
$ ("div"). Remove ("#father div");
})
How to add and delete a div dynamically