skip to Main Content

I have a site on shopify and everything is working fine except when we use the site on iOS safari browser and click the “add to cart” button, it doesn’t trigger the onclick function. It works fine for all the desktop browser and android phone browser aswell. The button just doesn’t trigger on iOS safari

Here is the snippet for the button:

<a onclick="cartAdd('AM',3)"><p class="icon-cart">Add to cart</p></a>

2

Answers


  1. Is the button like this?

    <button onclick="myFunction()"></button>
    

    If yes, you should use:

    button.addEventListener("click", myFunction);
    

    Else I can’t help you like you don’t give any code.

    Login or Signup to reply.
  2. Ok, what you can do is add a class to your button, and then add an event listener to it:

    document.getElementsByClassName("addToCartBtn")[0].addEventListener("click", function() {
        alert("Item added to cart!")
    });
    <a class="addToCartBtn"><p class="icon-cart">Add to cart</p></a>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search