user10897505
user10897505

Reputation:

Using 2 different body background colors

What would be the best way of doing 2 different background colors?

Code: https://playcode.io/test4343?tabs=index.html,preview

When it's first viewed it's one color,

https://i.sstatic.net/7p3Gs.png

After you click on circle, if I wanted to give it a different color how would I do that?

https://i.sstatic.net/9q3T1.png

body {
  background: #353198;
}

Upvotes: 0

Views: 62

Answers (2)

user9331887
user9331887

Reputation: 66

you can use

document.getElementsByClassName("jacketa").addEventListener("click", myFunction());
function myFunction (){
document.body.style.background="red";
}

Upvotes: 0

Muljayan
Muljayan

Reputation: 3886

You have to use an onclick function on the circle and then in that function include the following code.

document.body.style.backgroundColor = "YOUR_DESIRED_COLOR"; 

Upvotes: 1

Related Questions