get elements in javascript html code example
Example: get element in javascript
// Selecting an Element by id:
document.getElementById("elem-id");
// Selecting Elements by class:
document.getElementsByClassName("elem-class");
// Selecting Elements by tag name:
document.getElementsByTagName("div");
// Selecting Elements by name:
document.getElementsByName("elem-name");
/* This method is like a jQuery selector
( #elemId -> id, .elemClass -> class, h1 -> tag name) */
document.querySelector("h1");