Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created October 1, 2012 17:17
Show Gist options
  • Save mkuklis/3813128 to your computer and use it in GitHub Desktop.
Save mkuklis/3813128 to your computer and use it in GitHub Desktop.
zepto click and tap events for mobile & desktop
if ('ontouchstart' in window) {
// turn off click event
$(document)
.on('click', 'a', function(e) {
e.preventDefault();
e.stopPropagation();
})
.on('tap', 'a', function(e) {
window.location.href = $(e.currentTarget).attr('href');
});
}
else {
// delegate click to tap
$(document).on('click', 'a', function(e) {
$(e.currentTarget).trigger('tap');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment