innerText VS innerHTML
innerText - 문자를 가져올때 html 태그를 문자로 인식
innerHTML - 문자를 가져올때 html 태그를 태그로 인식
읽기만하면 잘 이해가 되지 않으니 코드를 보면서 이해하자!!
See the Pen Untitled by Lee-YuGyeong (@lee-yugyeong) on CodePen.
See the Pen Untitled by Lee-YuGyeong (@lee-yugyeong) on CodePen.innerText는 <a href='https://daum.net'>daum</a>"를 문자열로 출력한다.
innerHTML은 "<a href='https://daum.net'>daum</a>"를 가져와 태그로 인식하여 다음 바로가기 링크가 생성된것을 볼 수 있다.
'WEB' 카테고리의 다른 글
| javascript / 문자열을 만드는 세가지 방법 (0) | 2021.10.14 |
|---|---|
| [JavaScript] insertAdjacentHTML 와 insertAdjacentElement 알아보기 / 인접한 영역에 추가하는 방법 (0) | 2021.10.14 |
| [JavaScript] this (0) | 2021.10.14 |
| [JavaScript] HTML 요소 추가 / createElement (0) | 2021.10.14 |
| [JavaScript] 조건문 / if / else if / else (0) | 2021.10.13 |