Is there a way to create a new div within an existing div using JavaScript?
I'd like the following to happen:
- Create a new div with
class="three"and put it insidediv class="one". - Create a new div with
class="text"and put it insideclass="three"and add the text 'this is sample text'.
The end result should look like this:
.two{
width:700px;
height: 600px;
background-color: yellow;
}
.three{
width:300px;
height: 200px;
transform: translate(50%, -250%);
background-color: red;
}
.text{
text-align: right;
transform: translate(-5%, 440%);
color: black;
}
<div class="one">
<div class="two">
</div>
</div>
