Document in JavaScript
In JavaScript, a document is an object that allows access to and manipulation of the currently loaded HTML web page. To access any element on an HTML page, you can use the JavaScript document object. This object enables you to access and manipulate the currently loaded HTML page, starting with accessing the document object.
Finding HTML Elements in JavaScript
Here are some basic Methods to use to access HTML elements in JavaScript:
- document.getElementById(id)
- document.getElementsByTagName(name)
- document.getElementsByClassName(name)
Adding and Deleting Elements in JavaScript
Here are some important Methods to use to Add and Delete HTML Elements in JavaScript:
- document.createElement(element)
- document.removeChild(element)
- document.appendChild(element)
- document.replaceChild(new, old)
- document.write(text)