50
rated 0 times
[
57]
[
7]
/ answers: 1 / hits: 45519
/ 9 Years ago, sun, march 8, 2015, 12:00:00
I am looking to add/remove a class from another div when a link is pressed. I have searched through several answers and searched online but could not find an answer that worked for me.
Here is my code:
<nav id=primary-menu> <a class=menu-toggle>Browse</a>
<ul>
<li><a href=#>Home</a></li>
<li><a href=#>News</a></li>
<li><a href=#>Rumors</a></li>
<li><a href=#>Tutorials</a></li>
<li><a href=#>Miscellaneous</a></li>
</ul>
</nav> <!-- end #primary-menu -->
I am looking to add the class active
to #primary-menu
when .menu-toggle
is clicked.
For JS/jQuery, I've tried click
, toggle
, toggleClass
, I've tried inlining the code, I've tried external scripts. Nothing seems to work and I'm not sure why.
I'd really appreciate your responses. PS: I'm not the best with JS/jQuery.
More From » jquery