Created
March 28, 2019 13:18
-
-
Save mukoladeath/1efd07418b4a9dd4cef13b581fce7e96 to your computer and use it in GitHub Desktop.
bind one and double click, to single onclick event
This file contains hidden or 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
| //global var | |
| var lastClick = 0; | |
| $("#target").click(function() { | |
| var d = new Date(); | |
| var t = d.getTime(); | |
| if(t - lastClick < 400) { | |
| //two clicks | |
| }else{ | |
| //one click | |
| } | |
| lastClick = t; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment