What I am trying to do is check if a class is active with hasClass. If it is active and then the wrapper is clicked remove that class from the wrapper again.
This is what I have to remove the class:
$(function() {
$('.toggle-nav').click(function() {
// Calling a function in case you want to expand upon this.
toggleNav();
$('#site-wrapper.show-nav').click(function (){
$(this).removeClass('show-nav');
});
console.log('it worked');
});
});
But this code is removing the class as soon as it is clicked without checking "if" it is present. Even if it is not present, it removes it.
The