I have the code html
<div class="mobile"></div>
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="work.php">Work</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
I need to: On click add class to the ul
<div class="mobile"></div>
<ul id="nav" class="visible">
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="work.php">Work</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
I've tried:
jQuery(document).ready(function() {
jQuery('.mobile').click(function(){
jQuery('#nav').removeClass('selected')
jQuery('#nav').addClass('selected');
});
});
When I click the first time the js add the class selected as I want; but when I click again it does nothing, it should remove that class, but it doesn't work. How can I do this?
Does anyone know the answer to this?
jQuery('#nav').removeClass('selected')is missing a;in the end of the line.