Skip to content

Instantly share code, notes, and snippets.

@winsonwq
Created April 20, 2012 16:34
Show Gist options
  • Save winsonwq/2430161 to your computer and use it in GitHub Desktop.
Save winsonwq/2430161 to your computer and use it in GitHub Desktop.
once implementation
function once(elem, eventType, handler){
elem.addEventListener(eventType, function(evt){
handler.call(elem, evt);
elem.removeEventListener(eventType, arguments.callee/*, false */);
}, false)
}
once(document.getElementById('onceButton'), 'click', function(evt){
alert('just show once!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment