I have three divs, of which the first needs to have a set background color on page load (this is to show that this is the default choice and preselected)
I want that when the user clicks the 2nd or 3rd div that
- the 1st div's background color is removed / white
- the clicked div has the background color (grey)
Should the user click on the 1st div again, it should behave like the 2nd or 3rd div and take the background color.
I have the following code per below, but I can't remove the background color of the 1st div when any other div is clicked.
Could anyone help me please?
JSFiddle: https://jsfiddle.net/AlphaX/1zp8yehu/1/
.one {background-color: grey;}
[tabindex]:focus { background-color: grey;}
<div class="parent" tabindex="0">
<div class="one" tabindex="1">
one
</div>
<div class="two" tabindex="2">
two
</div>
<div class="three" tabindex="3">
three
</div>
</div>