<!doctype html>
<
html
>
<
head
>
<
title
>
isPreventDefault() Method
</
title
>
</
script
>
</
head
>
<
body
>
Go to Homepage
</
a
>
<
div
id
=
"initial"
></
div
>
<
div
id
=
"prevented"
></
div
>
<
div
id
=
"response"
></
div
>
<
script
>
$("a").click(function (event) {
$("#initial").html("Before: isDefaultPrevented? <
strong
>"
+ event.isDefaultPrevented() + "</
strong
>");
event.preventDefault();
$("#prevented").html("preventDefault() is called now.");
$("#response").html("So, you are not going anywhere."
+ " isDefaultPrevented? <
strong
>"
+ event.isDefaultPrevented() + "</
strong
>");
});
</
script
>
</
body
>
</
html
>
<!doctype html>
<
html
>
<
head
>
<
title
>
isPreventDefault() Method
</
title
>
<
script
src
=
</
script
>
</
head
>
<
body
>
<
form
action
=
"action.php"
>
Input:<
br
>
<
input
type
=
"text"
name
=
"input_1"
>
<
button
type
=
"submit"
>Submit</
button
>
</
form
>
<
script
>
$("button").click(function (event) {
if (event.isDefaultPrevented())
alert('Default action was prevented');
else
alert('Click Ok');
event.preventDefault();
if (event.isDefaultPrevented())
alert('Default action was prevented');
else
alert('Click Ok');
});
</
script
>
</
body
>
</
html
>