Skip to content
Advertisement

make menu header turn red one at a time?

Was recently trying to play around JavaScript until I got stuck here…

I made four menu headers, each of which when clicked turns red, to show that the menu header is “active”. The problem however is, I want just one to turn red at a time, instead of all menu headers turning red for every header clicked.

JavaScript
JavaScript
JavaScript

Please help me out anyone?

Advertisement

Answer

You need to cycle through the other menuHeaders and remove all the active_red classes first, and then apply the class to the current element.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement