문서 객체 모델 ( DOM, Document Object Model)

웹 브라우저가 HTML 페이지를 인식하는 방식

document 객체와 관련된 객체의 집합

html 페이지에 존재하는 태그를 자바스크립트에서 이용할 수 있는 객체로 만드는 것

 

메소드 이름

설명

createElement(tagName)

요소 노드 생성

createTextNode(text)

텍스트 노드 생성

appendChild(node)

객체에 노드를 연결

setAttribute(name, value)

객체의 속성을 지정

getAttribute(name)

객체의 속성을 가져옴

getElementById(id)

태그의 id속성이 id와 일치하는 객체를 가져옴

getElementsByName(name)

태그의 name속성이 name과 일치하는 문서 객체
를 배열로 가져온다

getElementsByTagName(tagName)

tagName과 일치하는 문서 객체를 배열로 가져온다

Posted by 공돌공돌
,