Skip to content

Instantly share code, notes, and snippets.

@leohxj
Last active December 22, 2015 15:28
Show Gist options
  • Select an option

  • Save leohxj/6492752 to your computer and use it in GitHub Desktop.

Select an option

Save leohxj/6492752 to your computer and use it in GitHub Desktop.
IE event listener
var addEvent = window.attachEvent||window.addEventListener;
var event = window.attachEvent ? 'onclick' : 'click';
addEvent(event, function(){
alert('Hello!')
});
// another
if (!someElement.addEventListener) {
_checkbox.attachEvent("onclick", setCheckedValues);
}
else {
_checkbox.addEventListener("click", setCheckedValues, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment