Trouble editing attributes with vanilla JavaScript

Dimwo
New Member
6 0 0

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?
0 Likes
LitExtension
Shopify Partner
626 65 115

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.

 

LitExtension - Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes