![]() ![]() Getting the first element matching the specified class else undefined. And output of the code will be as follows : Var myElements = document.getElementsB圜lassName('sample demo') Īfter clicking on “Change background color of elements with sample and demo class” button only the elements with classes having both sample and demo will be retrieved. Now let us learn how we can retrieve the elements of all the DOM with classes specified more than one in the parameter of the getElementsB圜lass() method.ĭemonstration of getting elements of a multiple class in javascriptĬhange background color of elements with sample or demo class Var myElements = document.getElementsB圜lassName("sample") for(var counter = 0 counter Īfter clicking on the “Change background color of elements with sample class” button output is as follows –ĭocument Scope with Multiple Classes. Let us change the background color of all the elements of the DOM who have sample class to pink.Ĭhange background color of elements with sample class ![]() ![]() Demonstration of getting elements of a particular class in javascriptĮDUCBA is the best platform to learn languages. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |