on pressing a link, I am calling a javascript function
<a id="eventFiringLink" href="javascript:functionName()">
and in another place of the code for a button I am binding the functionName()
function as a listener for a click event.
<button id="someButton">
binding click event by jquery
$("#someButton").bind('click',functionName);
and the function description is exactly like below.,
functionName(e)
{
if(event.target.id== "eventFiringLink")
{
console.log("do this");
}
else
{
console.log("do that");
}
}
when I clicked the link, I thought that I would get
"TypeError: Cannot read property 'target' of undefined",
but to my surprise the code got executed and printed
"do this"
in the console.
How is that possible.?