小编iLo*_*eJS的帖子

Could it be simpler?

I wrote a little vanilla JavaScript program, but I want to know if there is a possibility to write this simpler? With ES6+? But only with vanila JavaScript, no jQuery or other libraries / frameworks. Thanks in advance for the suggested solutions.

const red = document.getElementById('circleOne');
const green = document.getElementById('circleTwo');
const blue = document.getElementById('circleThree');

red.addEventListener("mouseover", () => {
  red.style.backgroundColor = "red";
});

red.addEventListener("mouseout", () => {
  red.style.backgroundColor = "white";
});

green.addEventListener("mouseover", () => {
  green.style.backgroundColor = "green";
  red.style.backgroundColor = "green"; …
Run Code Online (Sandbox Code Playgroud)

javascript css

2
推荐指数
1
解决办法
101
查看次数

标签 统计

css ×1

javascript ×1