728x90
#getElementById()
element = document.getElementById(id);
-id를 통해 엘리먼트를 반환한다.
-만약 document에 구체적인 id의 엘리먼트가 없다면 null을 반환한다.
#setAttribute()
-선택한 요소(element)의 속성(attribute)값을 정한다.
-element.setAttribute(attributename, attributevalue)
-attributename에는 속성이름, attributevalue에는 속성값
# createElement
-요소노드생성
#append
1.여러개의 요소를 추가
2. text로 추가가능
3.return 값이 존재하지않는다. (undefined)
4.prepend
-그냥 append는 부모요소의 맨 하단에 추가되는 것과 달리 prepend는 부모요소 아래 최상단에 위치시킨다.
#appendChild
1.하나의 요소만을 추가
2. text로 추가 불가능
3. return 값이 존재
728x90
'부트캠프교육중 > DOM' 카테고리의 다른 글
[DOM] 유효성검사 (회원가입창만들기) (0) | 2023.01.07 |
---|---|
[DOM] 이벤트객체 (0) | 2023.01.07 |
[DOM] Delete (0) | 2023.01.06 |
[DOM] Update (0) | 2023.01.06 |
[DOM] Read (0) | 2023.01.06 |