Skip to content

Instantly share code, notes, and snippets.

@liximomo
Created November 18, 2016 15:51
Show Gist options
  • Save liximomo/0b603992ac0932109e08609b0c06b992 to your computer and use it in GitHub Desktop.
Save liximomo/0b603992ac0932109e08609b0c06b992 to your computer and use it in GitHub Desktop.
dom utils
function addDOMEvent(html_element, event_name, event_function, useCapture)
{
if(html_element.addEventListener) {
html_element.addEventListener(event_name, event_function, useCapture); //don't need the 'call' trick because in FF everything already works in the right way
return;
}
//Internet Explorer
html_element.attachEvent("on" + event_name, function() { event_function.call(html_element); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment