Reputation: 3571
I've been using appendChild to add elements to pages, but I'm not always happy with where they end up... can someone explain to me how to put elements where I want them?
For example:
mytable.parentNode.appendChild (zNode, mytable);
places zNode (is zNode some official syntax or is it like everyone using 'i' as the variable in loops?) at the bottom of the table...
How do I put zNode at the TOP of the table instead?
For example... on THIS PAGE How would I place the button between where it says how many accomplishments and the top of the table?
How would I attach something above, below, or to the right or left of an image or other element?
Upvotes: 0
Views: 878
Reputation: 15053
appendChild adds the node at the end.
To place a node before your table you can use insertBefore:
mytable.parentNode.insertBefore(zNode, mytable);
To center a button you have to add text-align: center
to the parent:
<div style="text-align: center;">
<button>Click me</button>
</div>
Upvotes: 1