Javascript examples for DOM Event:preventDefault
Call preventDefault() method on event
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function onClick(e) {//from ww w. j a v a 2s . c o 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>