Skip to content
Advertisement

Need help combining class, active and before selectors

I’m trying to make an accordian menu (I’m a massive noob at HTML, CSS and JS as you can probably tell).

My main goal is to make the “+ Work” and “+ Social” buttons change to “- Work” and “- Social” respectively when active.

I tried using the ::before selector and I just can’t get it to work.

When I write .active::before {content: "- "; } it appends “- ” to the links within the accordian panel which I don’t want.

Please help!!

P.S I’m trying to copy this into a cargo website and for whatever reason it’s really temperamental so if anyone has advice/experience with this please let me know!

JavaScript

Advertisement

Answer

To select the active class you use . not :

Change

JavaScript

To

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