Using jQuery I want to switch class button when user click on it. This is the button code I have right now
<button type="button" class="btn btn-success btn-bordered" id="toggle-job">Grab this work</button>
Below the code to handle the button click
$('#toggle-job').click(function(e){
if ( $( this ).hasClass( "btn-success" ) ) {
$( this ).removeClass( "btn-success" ).addClass( "btn-custom" );
$( this ).text("Drop this work");
};
if ( $( this ).hasClass( "btn-custom" ) ) {
$( this ).removeClass( "btn-custom" ).addClass( "btn-success" );
$( this ).text("Grab this work");
};
$( "#action-box" ).toggle();
$( "#photoCrop" ).toggle();
});
The toggle code works properly...so the related divs show or hide I'm pretty sure I'm doing some silly error...but I'm not able to figure out what I'm doing wrong. Thanks a lot for any suggestion