DEV Community

infinity01012003
infinity01012003

Posted on

innerhtml hates event listeners

so i was working on a project and i found out that after i add event listeners to a element inside container and then if i add more html to it via .innerhtml += "html" method then the previous content stays along with the new one but the event listeners from the old content are destroyed and the only way to deal with it is to use append child which means you have to write the html using a lot of create element methods which is frustrating

Top comments (0)