Skip to content

Instantly share code, notes, and snippets.

@gabrieleromanato
Last active August 29, 2015 13:56
Show Gist options
  • Save gabrieleromanato/8931814 to your computer and use it in GitHub Desktop.
Save gabrieleromanato/8931814 to your computer and use it in GitHub Desktop.
jQuery/JS: single click event
// jQuery
$( "#button" ).one( "click", function() {
alert( "Test" );
});
// JS
var btn = document.getElementById( "button" ),
count = 0;
btn.addEventListener( "click", function() {
count++;
if( count == 1 ) {
alert( "Test" );
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment