JavaScript2_노드 삭제와 이동하기

🙋🏻‍♀️·2022년 4월 16일
0

✔️노드 삭제와 이동

const today = document.querySelector('#today');
const tomorrow = document.querySelector('#tomorrow');



✔️노드 삭제하기: Node.remove();

tomorrow.remove();-->오늘할일 목록 전체 사라짐
today.children[2].remove();-->오늘할일의 세번째 인덱스 지우기



✔️노드 이동하기: prepend, append, before, after

today.append(tomorrow.children[1]);//내일할일의 두번째 요소를 오늘 할일의 마지막에 넣음
tomorrow.children[1].after(today.children[1]);//오늘할일의 고양이청소를
//내일할일의 뮤지컬 공연예매로 옮김.

0개의 댓글

관련 채용 정보