Why does the onclick handler below trigger an ‘elem.parentNode is not a function’ error?
<html> <head> <script type='text/javascript'> function getParent(elem) { var parent = elem.parentNode(); } </script> </head> <body> <div style='border: solid black 2px'> <span onclick='getParent(this)'>hello</span> </div> </body> </html>
Your problem is that parentNode is not a function. Try removing the
().