I am trying to add a new element (HTML tag) into the content of a page via java script DOM, the tricky thing is that i would like to add it into the middle of content not just append it before or after a existing node. for example, I would like to change this <div>hello this is some sample text to illustrate a point</div> to this using the DOM <div>hello this is some <b>sample text</b> to illustrate a point</div> any ideas? Thanks
use this; https://developer.mozilla.org/en/DOM/element.insertBefore as to finding the middle; var c = containerHTMLelement; var middle = c.childNodes[Math.round(c.childNodes.length/2)]; c.insertBefore (newElement, middle);