What's the proper way to toggle a couple classes on click in jQuery?
1) HTML before click:
<button class="btn"><i class="icon-sign-blank"></i> Click me!</button>
2) HTML after click:
<button class="btn btn-success"><i class="icon-check"></i> Clicked!</button>
3) HTML after another click: (same as beginning)
<button class="btn"><i class="icon-sign-blank"></i> Click me!</button>
Current jQuery:
$('btn').on('click',function(e) {
$('btn > i').removeClass('icon-sign-blank').addClass('icon-check');
$('btn').addClass('btn-success');
});
But this works once, but not back again. What's the proper way to handle both directions?