Here is a code snippet I'm using to switch between classes for buttons:
$('button').on('click', function(){
var btn=$(this);
if(btn.attr('class')=='tct-button'){
btn.removeClass('tct-button').addClass('tct-button2');
}
else{
btn.removeClass('tct-button2').addClass('tct-button');
}
});
I need help with modifying this code so that when I click on a button in a div, any other buttons within the same div that were changed previously revert back to the default class 'tct-button'. Only the most recently clicked button should have the 'tct-button2' class. Can you assist me with this modification?