I have a question. So, I have 3 divs with background and another 3 divs with borders. I have to move div #1 with red background to the divs without backgrounds. If the div with red background matches with the divs with red borders it should be colored in red background. Please see the code. I am stuck as I am not able to make the div change the color.
let allDivs = document.querySelectorAll("#dd")
dd.addEventListener("click" , function(){
red.addEventListener("mousemove" , e=>{
red.style.left = e.clientX - 25 + "px"
red.style.top = e.clientY - 25 + "px"
})
blue.addEventListener("mousemove", e=>{
blue.style.left = e.clientX - 25 + "px"
blue.style.top = e.clientY - 25 + "px"
})
green.addEventListener("mousemove", e=>{
green.style.left = e.clientX - 25 + "px"
green.style.top = e.clientY - 25 + "px"
})
})
#dd{
width: 100%;
height: 100%;
display: inline-block;
}
#red{
width: 100px;
height: 100px;
border-radius: 50%;
background: red;
position: absolute;
}
#blue{
width: 100px;
height: 100px;
border-radius: 50%;
background: blue;
position: absolute;
}
#green{
width: 100px;
height: 100px;
border-radius: 50%;
background: green;
position: absolute;
}
#red1{
width: 100px;
height: 100px;
border-radius: 50%;
border:1px solid red;
margin-left: 300px;
}
#blue1{
width: 100px;
height: 100px;
border-radius: 50%;
border:1px solid blue;
margin-left: 300px;
}
#green1{
width: 100px;
height: 100px;
border-radius: 50%;
border:1px solid green;
margin-left: 300px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="dd">
<div id="red"></div>
<div id="red1"></div>
<div id="blue"></div>
<div id="blue1"></div>
<div id="green"></div>
<div id="green1"></div>
</div>
</body>
</html>