HTML DOM getElementById () method
Definition and Usage
getElementById () method returns the specified ID to the owner of the first object.
HTML DOM defines a variety of methods to find elements in addition to getElementById (), as well as getElementsByName () and getElementsByTagName ().
If no ID or null elements
If more of the specified ID exists an element of return undefined.
Browser Support
All major browsers support getElementById () method
grammar
document.getElementById( elementID )
Parameter s
参数 | 类型 | 描述 |
---|---|---|
elementID | String | 必须。元素ID属性值。 |
return value
类型 | 描述 |
---|---|
元素对象 | 指定ID的元素 |
technical details
DOM version | Core Level 2 Document Object |
---|