I have an HTML button to which I attach an event, using jQuery\'s bind()
, like so:
$(\'#mybutton\').bind(\'click\', myFirstHandlerFunction);
This would help add data-click-state
attribute on your button
$(document).ready(function() {
$('#mybutton').on('click', function() {
if ($(this).attr('data-click-state') == 1) {
$(this).attr('data-click-state', 0)
myFirstHandlerFunction();
} else {
$(this).attr('data-click-state', 1)
mySecondHandlerFunction();
}
});
});