Javascript examples for DOM Event:event function
Pass event itself into the event handler function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function onClick(e) {/*from w ww . j ava2 s . co m*/ if (e){ e.preventDefault(); } console.log(e); } </script> </head> <body> <a href="#" onclick="onClick(event)">Works</a> <br> <br> <a href="#" onclick="onClick()">Doesn't Work</a> </body> </html>