34
loading...
This website collects cookies to deliver better user experience
<!DOCTYPE html>
<html>
<head>
<title>This is some HTML page</title>
</head>
<body>
<p class="element-one">I am a paragraph</p>
<h1>I am an important element </h1>
</body>
</html>
// As an example, let us say we are looking for all the h1 elements
const elements = document.getElementsByTagName('h1');
// As an example, let us say we are looking for an element with the class of game
const games = document.getElementsByClassName('game');
// As an example, let us say we are looking for an element with id of username. Each HTML page can only have one such element that has the id that we are looking for.
const username = document.getElementById('username');
// As an example, let us say we are looking for an element with id of username. Each HTML page can only have one such element that has the id that we are looking for.
const username = document.querySelector('#username');
// As an example, let us say we are looking all elements that have the class of user on it.
const users = document.querySelectorAll('.user'); // Static Non-Live Node List