Javascript Inbuilt Methods: Part I

Here are the JS DOM inbuilt methods to get these HTML tags/elements:

  • document.getElementById(id)
  • document.getElementsByTagName(name)
  • document.getElementsByClassName(class)
  • document.querySelector(*)
  • document.querySelectorAll(*)

We can use these methods to update the HTML Dynamically.

Here are the examples:

1 document.getElementById(id)

<!DOCTYPE html>

<p id="demo">Click the button to change the text in this paragraph.</p>

<button onclick="myFunction()">Try it</button>

function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World";