Forum Moderators: open

Message Too Old, No Replies

createElement "DIV" Change other element position

         

insomnia2008

6:21 am on Sep 20, 2007 (gmt 0)

10+ Year Member



createElement "DIV" Change other element position

<div id="aa"><img src="http://www.google.com/intl/en_ALL/images/logo.gif" /></div>
<script>
function ss(){
var _div=document.createElement("div")
_div.style.overflow="hidden"
_div.appendChild(document.getElementById("aa"))
document.body.appendChild(_div)
}
</script>

<input type="button" value="button" onclick="ss()" />

daveVk

7:53 am on Sep 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this what you want to achieve?
- remove div "aa" from where it currently is
- create a new div as child of body
- insert "aa" as child of new div

If so then 1st step is missing, something like

var aaEl = document.getElementById("aa")
aaEl.parentNode.removeChild( aaEl );

Welcome to forum