Hackforge Academy

Category: javascript

what is dom

Published on 16 Jul 2026

Explanation

The DOM represents the HTML document as objects that JavaScript can access.

Code:

const heading = document.getElementById('title');

Explanation

getElementsByClassName() selects elements by class name.

Code:

const items = document.getElementsByClassName('item');

Explanation

querySelector() selects the first matching element.

Code:

const btn = document.querySelector('.btn');

Explanation

querySelectorAll() selects all matching elements.

Code:

const links = document.querySelectorAll('a');

Explanation

Selected elements can be modified using JavaScript.

Code:

heading.textContent = 'Welcome';

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community