hi,
i am working on javascript and i want to append img to a div. a div id to which img is to be appended is stored in hidden field. how should i append chilld to that div?plz help me on it.
Try this
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function MoveImage() { var id = document.getElementById("hfIds").value; var img = document.getElementById(id); document.forms[0].removeChild(img); var dv = document.getElementById("container"); dv.appendChild(img) } </script> </head> <body> <form id="form1"> <input type="button" id="demo" onclick="MoveImage()" value = "Demo" /> <input type="hidden" id="hfIds" value = "img1" /> <div id="container" style = "border:1px solid black;min-height:10px"> </div> <hr /> <img src="http://www.aspsnippets.com/images/Blue/Logo.png" id="img1" /> </form> </body> </html>
Demo
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.