Imagine a scenario where we have an unknown number of div elements. When we click on any element, it should change its background color. Is there a way to achieve this without relying on classes or ids?
NOTE: I came across some questions related to this topic, but they did not provide the solution I was seeking.
For example:
$(element).click(
function(){
$(element).css("background-color","#DDDDDD");
}
);
HTML:
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
CSS:
div{
height:10px;
width:10px;
float:left;
border-radius:50%;
margin:2px;
background-color:#00A2E8;
}