mardi 15 septembre 2015

Show/Hide button based on it's previous state with jQuery

I want to show a button when the user check/uncheck the checkbox. The checkbox can appear checked or unchecked for different users. How can I show/hide a button based on the previous state of the checkbox. my current code is below.

$('#receive-msg').on('click',function (){
var btnNoMsg = $('#btn-no-msgs');
   btnNoMsg.removeClass('hide').addClass('hide');
   btnNoMsg.removeClass('hide');
});

I know that I have to store the current state of the checkbox somewhere, and when is clicked again compare the previous state with the current state and show/hide the button.




Aucun commentaire:

Enregistrer un commentaire