For example, when I have:
<div class="abc123"></div> <!-- no child div -->
I want to insert a new div in it:
<div class="xyz">some content</div>
So that the outcome is:
<div class="abc123">
<div class="abc">Some Content</div>
</div>
How can I implement this using javascript?
in jQuery:
in Simple JS
Edit:
This following piece of code produces the same effect as done in the above mentioned jQuery code(edited in light of the comment by RobW ):