-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathevent.preventDefault.xml
More file actions
24 lines (24 loc) · 962 Bytes
/
event.preventDefault.xml
File metadata and controls
24 lines (24 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<entry name="event.preventDefault" type="method" return="undefined">
<signature>
<added>1.0</added>
</signature>
<desc> If this method is called, the default action of the event will not be triggered. </desc>
<longdesc> <p>For example, clicked anchors will not take the browser to a new URL. We can use <code>event.isDefaultPrevented()</code> to determine if this method has been called by an event handler that was triggered by this event.</p> </longdesc>
<example>
<desc>Cancel the default action (navigation) of the click.</desc>
<code><![CDATA[
$("a").click(function(event) {
event.preventDefault();
$('<div/>')
.append('default ' + event.type + ' prevented')
.appendTo('#log');
});
]]></code>
<html><![CDATA[
<a href="http://jquery.com">default click action is prevented</a>
<div id="log"></div>
]]></html>
</example>
<category name="Event Object" slug="event-object"/>
<category name="Version 1.0" slug="1.0"/>
</entry>