I want to change the behavior of a button by changing the class.
On the first click, I see the alert" Step1: Class starts as Step1" as expected.
On the second click: "Step1: Class starts as Step2"
The class changes, but the selector seems stuck. What am I missing here?
Thank you!
$(document).ready(function () {
$("#GoToNextStep").addClass('Step1');
$(".Step1").click(function(e) {
alert ('Step1: Class starts as ' + $(this).attr('class'));
$(this).removeClass();
$(this).addClass('Step2');
alert ('Class set to ' + $(this).attr('class'));
});
$(".Step2").click(function(e) {
alert ('Step2: Class starts as ' + $(this).attr('class'));
$(this).removeClass();
$(this).addClass('Step3');
alert ('Class set to ' + $(this).attr('class'));
});
});