Last active
August 29, 2015 14:23
-
-
Save jcastellanos003/b5443b982147ef22118f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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