Here's the changed script
<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("img1");
document.forms[0].removeChild(img);
var dv = document.getElementById(id);
dv.appendChild(img)
}
</script>
</head>
<body>
<form id="form1">
<input type="button" id="demo" onclick="MoveImage()" value = "Demo" />
<input type="hidden" id="hfIds" value = "container" />
<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