Prev Demo
jQuery
>
Event.Preventdefault() - Stop Default Behavior Of Element
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <style> #div3 { color:red; background-color:lightgreen; } </style> </head> <body> <a id="aPreventDefault" href="http://www.itfunda.com">preventDefault() - Ideally it should go to Attributes.aspx page</a> <br/> <br/> <div id="div3">This is DIV3, By clicking on the above Hyperlink, the sentence in the DIV3 changed.</div> <script> $("#aPreventDefault").click(function (e) { e.preventDefault(); $("#div3").text("sorry default behavior is prevented"); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output