I am trying to add and remove class using jquery click function. It works for the first click but I don't know why it is not working for the second click. It not showing any errors as well.
Here is the html
<p class="right hand hidesubcategory">Hide</p>
And the script:
$('.hidesubcategory').click(function() {
$(this).text('Show');
$(this).removeClass('hidesubcategory').addClass('showsubcategory');
});
$('.showsubcategory').click(function() {
$(this).text('Hide');
$(this).removeClass('showsubcategory').addClass('hidesubcategory');
});
Thanks in advance