/
How do we target elements using their classes?

How do we target elements using their classes?

How would we change the first element with the class “MENUmenu”.

var Elements = document.getElementsByClassName("MENUmenu"); var Menu = Elements[0]; Menu.innerHTML = "We got to target this element";

This would require some HTML with a class like this:

<html> <body> <p>Some example HTML</p> <div class="MENUmenu"></div> </body> </html>

Related content

Javascript Concepts to avoid
Javascript Concepts to avoid
Read with this
DOM Element
DOM Element
More like this
Typescript is a bad idea
Typescript is a bad idea
Read with this
How to use the class attribute of HTML elements.
How to use the class attribute of HTML elements.
More like this
Javascript Concepts - Start Here!
Javascript Concepts - Start Here!
Read with this
Move a div to an absolute position
Move a div to an absolute position
More like this