Search code examples
javascriptiosiphoneipadmouseover

some javascript functions don't work on iOS devices (iPhone, iPad)


hope you can help me. I'm freaking out after spending several days trying to solve this problem.

My JavaScript mouse event functions don't work on iOS devices. I red this apple article and i added to my html tags this attribute: onclick="void(0)" but it just doesn't want to work. i can trigger an alert message on any mouse events like this:

document.getElementById("el").addEventListener("mousedown", function(){
alert("Bla-Bla");
)};

but stuff like this inside the same eventlistener is not being executed:

document.getElementById("el").classList.remove("bla-class");

does somebody maybe know if there is a solution for this problem?


Solution

  • You changed the order of the brackets in your code, especially in the last line! It should be like this:

    document.getElementById("el").addEventListener("mousedown", function(){
      alert("Bla-Bla");
    });