V.Vidhya Logo

V.Vidhya

DOM Events I


Q1.

Create a simple HTML + CSS with a h1 heading and 3 button as per the image.

Image 1

Initially the heading is in black color.

Now write a JS functionality to change the color of heading based on which respective color of button is clicked.


Q2.

Make a on-off button using JS.

For e.g.

let’s say we initially have a button in this on state.

Image 2

Once you click on it, it goes into off state.

Image 3

Now if it’s clicked again, it will be in on state.

Use classList and its relevant methods to change styling of a button based on in which state it is currently.


Prev Post
DOM Cumulative II
Next Post
DOM Events II