JavaScript Tutorial in Hindi for Beginners [Part 40] - How to select element by class in JavaScript

preview_player
Показать описание
#Javascript #Tutorial #Hindi

In this video i will talk about how to select an element by class in JavaScript

To select elements by a given class name, you use the getElementsByClassName() method:

The getElementsByClassName() method returns a collection of elements whose class name is the CSS class that you pass into the method. The return collection is a NodeList.

Once you selected an element, you can add styles to the element, manipulate its attributes, and traversing to parent and child elements.

Since the getElementsByClassName() is a method of the Element, you can select elements with a given class inside a container.

The HTMLCollection object represents a collection of nodes. The nodes can be accessed by index numbers. The index starts at 0.

Tip: You can use the length property of the HTMLCollection object to determine the number of elements with a specified class name, then you can loop through all elements and extract the info you want.

Join this channel to support Tech Gun:
Рекомендации по теме
Комментарии
Автор

Aesaa abhi tak kisi nee nahii samjha yaa sir 👍👍👍

mohitshastri
Автор

Done with 40th Lecture 👍.. Great Growing

dernyt-tpe
Автор

Sir you are great please upload advance react JS tutorial please sir

lovelymusic
Автор

Sir all video upload krdo jldi maine job interview k liye preparing krni aa

rakeshuthapa
Автор

Nd ek website help of HTML CSS JS ki video upload krdo sir baut help ho jayegi es se

rakeshuthapa
Автор

Sir, when i execute the code document. Getelementbyclass name its showing uncaught error... i.e it is not a function

aditikumari
Автор

Sir aap react pee bhii video banee gee because you have uniq teaching style

mohitshastri
Автор

Sir try to upload any basic project... I am waiting...

sachinrawat
join shbcf.ru