Skip to content

Instantly share code, notes, and snippets.

@jcastellanos003
Last active August 29, 2015 14:23
Show Gist options
  • Save jcastellanos003/b5443b982147ef22118f to your computer and use it in GitHub Desktop.
Save jcastellanos003/b5443b982147ef22118f to your computer and use it in GitHub Desktop.
//defined function
function doSomething(msg){
alert(msg);
}
//attach event for h1 elements
document.querySelector('h1').onclick = function () {
doSomething('h1: Event OnClick attached');
};
//attach event with addeventlistener
function attachHtmlEvents(){
var e = document.getElementById('someid');
e.addEventListener('click', doSomething('Event attached'), false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment