The issue lies in the fact that the variable currentclass
is being assigned a value like "content2 active" instead of just "content2".
To rectify this, you could consider implementing the following code snippet:
var currentclass = $(this).attr('class');
$(this).addClass('active');
For reference, you can view an example at: http://codepen.io/anon/pen/qbAdG
Utilizing a debugger can be extremely beneficial in situations like these. A debugger allows you to step through the code, inspect variables, and analyze the program's flow to ensure everything is functioning correctly.