I have the javascript code for a link click:
document.getElementById('giddy').onclick = function {
alert(this.href);
};
and I want to separate the function part of it…I have
document.getElementById('giddy').onclick = poro(this);
function poro(yyyy) {
alert(yyyy.href);
};
But it is not working (says undefined in the alert)…what am I doing wrong?
You don’t need to pass
thisas a parameter.thiswill be the context for the function when it is called. You should just have: