I have 4 Spans and I'm looking to create an interactive feature where clicking a link in a span changes the color of that span. Additionally, when another link in a different span is clicked, the color of that span changes while reverting the previously clicked span back to its original color. I know this might sound confusing, but please bear with me. Below is some JavaScript code I found from another user's question. I've tried modifying it to suit my needs without much success. As a beginner in JavaScript, any tips or assistance would be greatly appreciated. Thank you in advance!
<script>
$(document).ready(function() {
$("#sec1").click(function() {
$("#sec1").removeClass('active');
$(this).addClass('active');
});
});
</script>
CSS:
#sec1 { height: 8vh; width:10%; text-align:center; position: fixed; top:9vh; left:0; background: rgb(238,238,238); /* Old browsers */
background: #7d7e7d; /* Old browsers */
...
html:
<span id="sec1" class="box"><a href="" class="one""><p style="margin-top:2.5vh; font-size:1.25em;"><b>MOVIES</a></p></div>
<span id="sec2" class="box"><a href="" class="two""><p style="margin-top:2.5vh; font-size:1.25em"><b>MUSIC</b></p></a></div>
<span id="sec3" class="box" ><a href="" class="three""><p style="margin-top:2.5vh; font-size:1.25em"><b>RADIO</b></p></a></div>
<span id="sec4" class="box"><a href="" class="four"><p style="margin-top:2.5vh; font-size:1.25em"><b>COMICS</b></p></a></div>