Reputation: 91
This looks awkward but when I'm trying to add any class or remove any class using jQuery it's not working, Instead of adding or removing class I tried with the alert window, in that case, it's working fine. Can anyone tell me why I'm not able to add or remove any class?
$('#sign').click(function(){
alert("I'm working");
$('#signup').ready(function(){
$(this).addClass('hidden');
});
});
This is the code I've tried and #sign
is the id in Sidebar or navbar whatever. When I click on that link then it goes to the section with id #signup
. In this section I want that class to add or remove.
Upvotes: 2
Views: 73
Reputation: 3126
See: https://api.jquery.com/ready/
$('#signup').ready(...)
does not seem applicable. The page is already loaded, so you do not need to wait for DOM ready. Just remove that wrapper and manipulate the class directly:
$('#sign').click(function(){
alert("I'm working");
$('#signup').addClass('hidden');
});
I am assuming you are trying to handle clicking on and changing the classes on DIFFERENT elements (despite the similar names).
Upvotes: 1