jQuery iOS .click() glitch
by Riley MacDonald, August 2, 2013

I was developing a drop down menu using jQuery and CSS. The menu’s were working great on all devices except for iOS with touch.
Turns out the Safari browser will fire a CSS element:hover event before a jQuery element.click() event. This causes the first touch of the element to do nothing, but any touch following will work fine.

CSS:

1
2
3
  .element:hover {
    /*Do Something*/
  }

jQuery:

1
2
3
  $('.element').on('click', function(){
    //Do Something
  });

Once the CSS was removed from the element, the jQuery click fired without a problem.

Open the comment form

Leave a comment:

Comments will be reviewed before they are posted.

User Comments:

Be the first to leave a comment on this post!