Imagine I have 3 different spans on a page that, when clicked, reveal something. Now, I want to change the color of the selected div.
<div class="step_wrapper">
<div id="step_box1"> <span>Content for page 1</span>
</div>
<div id="step_box2"> <span>Content for page 2</span>
</div>
<div id="step_box2"> <span>Content for page 3</span>
</div>
</div>
I attempted to achieve this by:
$("#step_box1").toggle(function() {
$(this).css("background-color", "red");
},
function() {
$(this).css("background-color", "");
});
For the second div:
$("#step_box2").toggle(function() {
$(this).css("background-color", "red");
},
function() {
$(this).css("background-color", "");
});
And for the third one:
$("#step_box3").toggle(function() {
$(this).css("background-color", "red");
},
function() {
$(this).css("background-color", "");
});
However, what I actually need is to only select one at a time and have the selected one change color while the others revert back to normal.