I've been trying to learn something about JavaScript today, came across events and somehow I'm stuck at it.
When I call the first function it just works, however if I call the second one it doesn't execute the function for some reason? I've tried doing it without the windows.onload event I've tried putting the script code inside head element or just above the closing body tag but nothing has changed, any tips?
function peh() {
document.onclick = function(){
alert("you clicked");
}
}
function second(){
var myElement = getElementsByTagName("mImg");
myElement.onclick = function(){
alert("clicked img");
}
}
window.onload = function() {
second();
}