Skip to content

[DOM] Does the event listener disappear when innerHTML is manipulated? #24

Answered by hochan222
hochan222 asked this question in Q&A
Discussion options

You must be logged in to vote

https://stackoverflow.com/questions/595808/is-it-possible-to-append-to-innerhtml-without-destroying-descendants-event-list

헐.. innerHTML 을 사용하면 자식의 모든 노드는 파괴된다.


  const render = (JSX: string): void => {
    const sectionElement = document.getElementById('app');
    if (sectionElement) {
      sectionElement.insertAdjacentHTML('beforeend', JSX);
      // sectionElement.innerHTML += JSX;
    }
    return ;
  };

insertAdjacentHTML 로 변경!

Replies: 1 comment

Comment options

hochan222
Jun 2, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by hochan222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant