Last active
August 11, 2017 10:02
-
-
Save dingo-d/906897d87e47546328e050a9df812efc to your computer and use it in GitHub Desktop.
A list of neat JavaScript snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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