manishjangir manishjangir - 3 months ago 7
HTML Question

create child div in a parent div using jquery

I have the following div structure

<div id="main_div">
<div id="lastChildDiv"></div>
</div>


now I want to create or append a new
div
above the div id of
lastChildDiv
. Then how to do it?

Answer

Use prepend

$('#main_div').prepend('<div id="new_div">...</div>');
Comments