Skip to content

Instantly share code, notes, and snippets.

@dingo-d
Last active August 11, 2017 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dingo-d/906897d87e47546328e050a9df812efc to your computer and use it in GitHub Desktop.
Save dingo-d/906897d87e47546328e050a9df812efc to your computer and use it in GitHub Desktop.
A list of neat JavaScript snippets
// iOS double click issue on menu
$('nav > ul > li a').on('touchend', function(event) {
window.location.href = $(this).attr('href');
});
// Doubleclick prevent; from http://stackoverflow.com/a/28566136/629127
function my_function(e) {
const $this = $(e.currentTarget);
e.preventDefault();
if (!$this.data('lockedAt') || Number(new Date()) - $this.data('lockedAt') > 300) {
// Code goes here
}
$this.data('lockedAt', Number(new Date()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment