Javascript examples for DOM Event:preventDefault
Use e.preventDefault() to stop an event
<!doctype html> <html lang="en"> <head> <title>html demo</title> </head> <body> <a id="navlink" href="http://google.com">Click me</a> <div id="Reveal"> Not Clicked/*from w w w . j ava 2 s . com*/ </div> <script> document.getElementById('navlink').addEventListener("click" , function(e){ e.preventDefault(); document.getElementById('Reveal').innerHTML = "Clicked"; },false); </script> </body> </html>