[JavaScript] textContent vs innerHTML

cho yunsu·2021년 5월 11일
0
  1. dom.textContent = <h1>blabla</h1>
    출력결과 : <h1>blabla</h1>
    textContent는 간단한 동작으로서 HTML태그를 해석하지 않는다.

2.dom.innerHTML = <h1>blabla</h1>
출력결과 : blabla
innerHTML은 HTML태그를 해석하여 변환한다. 업데이트 안되는 것을 지정할 때 쓴다.

  • innerText는 웬만하면 쓰지말자.
profile
Growing Developer!!

0개의 댓글