JAVASCRIPT Tutorial
<html>
tag.<body>
tag.<head>
tag.document
. This returns the document object.document.body
for the body and document.head
for the head.document.getElementById(id)
.document.querySelector(selector)
for the first matching element and document.querySelectorAll(selector)
for all matching elements.// Get a reference to the document object
const doc = document;
// Explore its properties and methods
console.log(doc.title); // Outputs the document's title
console.log(doc.body.innerHTML); // Outputs the HTML content of the body
// Select elements by ID
const elementById = doc.getElementById("element-id");
// Select elements by CSS selector
const elementsByClass = doc.querySelectorAll(".element-class");
// Perform operations on selected elements
elementById.style.color = "red"; // Changes the element's text color to red