DEV Community

Cover image for DOM ELEMENTS SELECTOR
Vinoth Kumar
Vinoth Kumar

Posted on

DOM ELEMENTS SELECTOR

ELEMENT SELECTORS :

A fundamental aspect of web development with JavaScript.

It allows developers to interact with and manipulate elements on a webpage dynamically.

TYPES OF ELEMENTS SELECTOR :

getElementById.
querySelector.
querySelectorAll.
getElementsByClassName.
getElementsByTagName.

getElementById() :

This method selects a single element by its unique ID attribute.

SYNTAX :

document.getElementById('id')

querySelector() :

The first element that matches a specified CSS selector. It returns only one element.

SYNTAX :

document.querySelector('selector')

Top comments (0)