javascript inserting html code
Posted
by Marius
on Stack Overflow
See other posts from Stack Overflow
or by Marius
Published on 2010-05-06T16:09:20Z
Indexed on
2010/05/06
16:18 UTC
Read the original article
Hit count: 207
Hello,
I have a situation when there's a table and you can add a new row by clicking a button. The row is dynamically generated by a server and it is passed back in HTML. So basically what i need to do is prefix the new row to the old table. Something like this:
tableelement.innerHTML = newHtml + tableelement.innerHTML;
That surely works, but i have a table header and, obviously, i need to insert the new html after it. How would i do this? insertBefore or insertAfter can't help (afaik), because they're meant for inserting elements and not unparsed HTML. So how could i, having an object of the header's row, insert another row (in HTML) after it (or before) ?
Thank you for your ideas
© Stack Overflow or respective owner