Revision: 65509
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 10, 2013 02:37 by jbernus
Initial Code
var isTouchSupported = 'ontouchstart' in window;
var startEvent = isTouchSupported ? 'touchstart' : 'mouseenter';
var endEvent = isTouchSupported ? 'touchend' : 'mouseleave';
$('.yourclass').on(startEvent,function(){
doSomething(this);
});
$('.yourclass').on(endEvent,function(){
doSomething(this);
});
Initial URL
Initial Description
Hover events can be irrelevant on mobile devices relying on touch events. This script switches the classical desktop hover events to touch events. Inspired by: http://jbkflex.wordpress.com/2012/07/12/javascript-touch-event-or-mouse-event-detect-and-handle-according-to-device/
Initial Title
Switch hover/touch events for Desktop/mobile devices
Initial Tags
Initial Language
JavaScript