javascript - Moving a div by its class inside another div with an ID -
i trying move div class="somediv" into/inside div id="parentdiv"
if edit javascript move div id div diff id works. moving div class div id not working. missing something?
html
<div id="parentdiv"> <div id="childdiv"> <ul> <li>1</li> <li>2</li> </ul> </div> <!-- move somediv here --> </div> <div class="somediv">some content</div>
js:
document.getelementbyid('parentdiv').appendchild(document.getelementsbyclassname('somediv'));
using jquery makes easier, @ updated version of jsfiddle , can see item has been moved, inspecting dom tree
$(document).ready(function(){ $("#parentdiv").append($(".somediv")); });
Comments
Post a Comment