Answer the question
In order to leave comments, you need to log in
Why doesn't blocking the button after it is pressed, JS?
Hello! It turns out the situation is, I need to remove the button after it is pressed, I did this .
Everything works great, but I can't figure out why the same code doesn't work on my site .
Although the html code of the button is completely identical, can anyone tell me, I have been suffering with this issue for a very long time.
Answer the question
In order to leave comments, you need to log in
and maybe there are more blocks with the class "simplecheckout-button-right" on the site,
it seems to me that in your js block you need a closure:
const simplecheckoutButtonRight = document.querySelectorAll(".simplecheckout-button-right");
simplecheckoutButtonRight.forEach(el => {
const btn = el.querySelector(".button");
((b)=>{
b.addEventListener("click", function() {
this.remove();
});
})(btn)
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question