Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js how to to attach an event handler only once

document.getElementById("myelement").addEventListener("click", handler);

// handler function
function handler(e) {
	// remove this handler
	e.target.removeEventListener(e.type, arguments.callee);

	alert("You'll only see this once!");
}
Source by www.sitepoint.com #
 
PREVIOUS NEXT
Tagged: #js #attach #event #handler
ADD COMMENT
Topic
Name
6+9 =