Course
summary


    0 chapters available

Loading...

Make your website interactive with JavaScript

Difficulty: Beginner ● Progress: 0 / 0 modules completed

Changing the style of an element

There are several ways to modify the style of an element. Previously we modified the style of our button by changing its id, but this is not a good practice.

The best method is instead to add a class to it! Simply use the classList attribute and its add method, like this:

sendButton.classList.add("hidden");

If the class is defined in your CSS, you will see that your element will change style immediately!

You need a free account to read this module