How to move HTML element to another element. Note that, I don't mean moving element's position. Consider this HTML code:
<div id="target"></div> <span id="to_be_moved"></span>
I want to move "to_be_moved" to "target" so "target" has child "to_be_moved" now. So the result should be like this:
<div id="target"><span id="to_be_moved"></span></div>
I've searched in google (especially using prototype framework) but all I've got is moving position, not as I want. Thanks before.
All you have to do is select the element(s) you want to move, then call an “adding” method such as append() , appendTo() or prepend() to add the selected elements to another parent element.
To set text alignment in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property text-align for the center, left and right alignment.
In your HTML, you'd give the div a class name like "center." You can then use the class selector .center to style it with the margin, width, border, and padding properties.
document.getElementById('target').appendChild( document.getElementById('to_be_moved') )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With