使用 2 种不同的 body 背景颜色
Using 2 different body background colors
制作 2 种不同背景颜色的最佳方法是什么?
代码:
https://playcode.io/test4343?tabs=index.html,preview
第一次看到它是一种颜色,
https://i.imgur.com/gQVK7r8.png
点击圆圈后,如果我想给它一个不同的颜色,我该怎么做?
https://i.imgur.com/oDe8raQ.png
body {
background: #353198;
}
您必须在圆上使用 onclick 函数,然后在该函数中包含以下代码。
document.body.style.backgroundColor = "YOUR_DESIRED_COLOR";
你可以使用
document.getElementsByClassName("jacketa").addEventListener("click", myFunction());
function myFunction (){
document.body.style.background="red";
}
制作 2 种不同背景颜色的最佳方法是什么?
代码: https://playcode.io/test4343?tabs=index.html,preview
第一次看到它是一种颜色,
https://i.imgur.com/gQVK7r8.png
点击圆圈后,如果我想给它一个不同的颜色,我该怎么做?
https://i.imgur.com/oDe8raQ.png
body {
background: #353198;
}
您必须在圆上使用 onclick 函数,然后在该函数中包含以下代码。
document.body.style.backgroundColor = "YOUR_DESIRED_COLOR";
你可以使用
document.getElementsByClassName("jacketa").addEventListener("click", myFunction());
function myFunction (){
document.body.style.background="red";
}