Selecting Elements in JavaScript
Selecting Elements
All HTML elements are objects. The document object has methods that allow you to select the desired HTML element.
Methods to select elements in JavaScript are:-
1. finds element by id:-
document.getElementById(id)
2. finds elements by class name:-
document.getElementsByClassName(name)
3. finds elements by tag name:-
document.getElementsByTagName(name)