Trouble editing attributes with vanilla JavaScript

I’m having an issue when trying to remove/add a class and replacing text on the page. Specifically, I’m having a button change from add to remove after being clicked; I can see the text of the button changed, but it quickly reverts back afterwards. Same problem when removing or adding a class. Changes are made, but reverted back in split second. My code is basically

function changeButtonText(id){
     const addButton = document.getElementById(id);
  
    addButton.innerText = 'Remove';
}

I can see in the inspector it briefly changes, and then reverted back to add. I have no idea what could be causing this. Any insights?

Hi @Dimwo ,

Can you please share your store URL and screenshot about your problem? So I can check and give you the best solution in this case.