html - Javascript function not called when id and function name same -


i want know effect of id , function when both same. example:

<tr> <td><img id='deleteauthor' onclick='javascript: deleteauthor(this)' src='images/close.png' /></td></tr>";         function deleteauthor(element){             alert(element);         }     output:typeerror: deleteauthor not function     [break on error]          <tr> <td><img id='deleteauthorbt' onclick='javascript: deleteauthor(this)' src='images/close.png' /></td></tr>";        function deleteauthor(element){         alert(element);       }     output:object htmlimageelement 

please why behave so?

u have use different names id , function. same names both cause ambiguity


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -