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.