Replacing Text Nodes With DOM Nodes

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2010-06-04T07:54:31Z Indexed on 2010/06/05 18:12 UTC
Read the original article Hit count: 269

Filed under:

Hey, say I have a text node via XPath. How would I replace the text node with a new DOM node? For example, this little patch of code will go through text nodes, and if text matches something, it will replace it with a corresponding image via img element.

I wanted something faster then a global page regex or even a element innerHTML regex. Any help would be appreciated.

EDIT: Never mind. I figured it out.

© Stack Overflow or respective owner

Related posts about JavaScript