Study Output for Myself/Javascript

[JS]insertAdjacentHTML

Dahyee 2022. 8. 24. 13:13

✅insertAdjacentHTML

HTML 요소를 가져와서 그 앞, 뒤, 첫번째 child, 마지막 child에 새로운 요소를 넣을 수 있는 method

element.insertAdjacentHTML(position, text);

position에는 다음 4가지만 올 수 있다.

beforebegin
요소 앞에

afterebegin
요소의 첫번째 child로

beforeend
요소의 마지막 child로

afterend
요소의 뒤에