Klaviyo Connect Event
Best answer by Dov 6 October 2022, 20:07
Thanks for sharing this with us.
As a first step, since your buttons have multiple classes, I recommend targeting one of the “common denominator classes” in your added to cart snippet that is consistent for all buttons that isn’t changing i.e. btn--add-to-cart
If that doesn’t work, you can try targeting the parent class telling it to find any nested buttons. This would require a query selector as oppose to getElementByClassname:
Let’s say this is your set-up:
<div class="parent-div"> <button class="btn--add-to-cart">Add To Cart</button></div>
You could adapt the querySelector portion to something like:
document.querySelector('div.parent-div > button')
I hope that’s helpful.
Don't be shy and see who else has similar interests.
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.
Links & Resources