Hi, I have a function that reads the content of an element, replaces a word with a link and then rewrites the content back into the element, obviously this means that all events that where previously set are lost. Does anyone know of a function/method that could find and replace content of an element without loosing the events? Thanks.
Edit: Without using a library
Here is my current code that does not destroy the events but turns < for example into < so I can not append HTML. This is the closest I have got.
element.appendChild(document.createTextNode(content));
My original code worked but got rid of the events.
element.innerHTML += content;