# Document interface
1. getElementById(id)
: Id를 이용해 Element에 접근할 때 사용하는 함수이다. 태그의 id를 매개변수로 받아서 id에 해당하는 element를 반환해준다.
getElementById
introduced in DOM Level 2Element
that has an ID attribute with the given value. If no such element exists, this returns null
. If more than one element has an ID attribute with that value, what is returned is undefined. The DOM implementation is expected to use the attribute
Attr.isId
to determine if an attribute is of type ID.
Note: Attributes with the name "ID" or "id" are not of type ID unless so defined.
elementId
of typeDOMString
- The unique
id
value for an element.
The matching element or |
2. getElementsByTagName(name)
: TagName을 이용해 Element에접근할 때 사용한다. 태그의 이름을 매개변수로 받으며 일치하는 태그 이름의 Elements를 반환한다.
여러개의 Element가 반환되면 배열로 값이 반환.
getElementsByTagName
NodeList
of all the Elements
in document order with a given tag name and are contained in the document.
tagname
of typeDOMString
- The name of the tag to match on. The special value "*" matches all tags. For XML, the
tagname
parameter is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use.
3. createElement(tagName)
: 새로운 Element 생성한다. 해당 태그이름의 Element를 새롭게 생성한 뒤 Element Object를 반환한다.
createElement
Element
interface, so attributes can be specified directly on the returned object.In addition, if there are known attributes with default values,
Attr
nodes representing them are automatically created and attached to the element.To create an element with a qualified name and namespace URI, use the
createElementNS
method.
tagName
of typeDOMString
- The name of the element type to instantiate. For XML, this is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use. In that case, the name is mapped to the canonical form of that markup by the DOM implementation.
INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the |
4. createTextNode(data)
: 새로운 TextNode를 생성한다. data를 가지는 TextNode를 생성한 뒤 Text Object를 반환한다.
createTextNode
'JavaScript' 카테고리의 다른 글
JSON (0) | 2016.04.08 |
---|---|
Node interface (0) | 2016.04.07 |
DOM (0) | 2016.04.06 |
내장 객체 - String (0) | 2016.04.05 |
Array (0) | 2016.04.04 |