WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript The HTML DOM Document Object


The HTML DOM Document Object

If you want to access any element in an HTML page, you always start with accessing the document object.


Finding HTML Elements

Method Description
document.getElementById(id) Find an element by element id
document.getElementsByTagName(name) Find elements by tag name
document.getElementsByClassName(name) Find elements by class name

Adding and Deleting Elements

Method Description
document.createElement(element) Create an HTML element
document.removeChild(element) Remove an HTML element
Remove an HTML element Replace an HTML element
document.write(text) Write into the HTML output stream