Based on a question answered earlier on SO, I’ve make this script which adds a CSS class to an element onClick. The problem is that it only works one time. How do I reset the function?
This is the jQuery code:
jQuery(function() {
jQuery('.close-button').click(function(){
jQuery(".content-display").addClass("cover");
jQuery(".close-button").addClass("cover");
});
jQuery('.project').click(function(){
jQuery('.content-display').addClass("uncover");
jQuery('.close-button').addClass("uncover");
});
});
And a fiddle with everything.
You need to remove alternative class on action. After you press both close and project in your current code, you have both cover and uncover classes
For this particular case usage of uncover class seems to be unnecessary, I vote for simple removeClass solution (@Stuart Feldt)