Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (68 sloc) 2.984 kb
<?xml version="1.0"?>
<entry type="method" name="mouseup" return="jQuery">
<title>.mouseup()</title>
<desc>Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element.</desc>
<signature>
<added>1.0</added>
<argument name="handler(eventObject)" type="Function">
<desc>A function to execute each time the event is triggered.</desc>
</argument>
</signature>
<signature>
<added>1.4.3</added>
<argument name="eventData" type="PlainObject" optional="true">
<desc>A map of data that will be passed to the event handler.</desc>
</argument>
<argument name="handler(eventObject)" type="Function">
<desc>A function to execute each time the event is triggered.</desc>
</argument>
</signature>
<signature>
<added>1.0</added>
</signature>
<longdesc>
<p>This method is a shortcut for <code>.bind('mouseup', handler)</code> in the first variation, and <code>.trigger('mouseup')</code> in the second.</p>
<p>The <code>mouseup</code> event is sent to an element when the mouse pointer is over the element, and the mouse button is released. Any HTML element can receive this event.</p>
<p>For example, consider the HTML:</p>
<pre><code>&lt;div id="target"&gt;
Click here
&lt;/div&gt;
&lt;div id="other"&gt;
Trigger the handler
&lt;/div&gt;
</code></pre>
<p class="image">
<img src="/resources/0042_05_02.png" alt=""/>
</p>
<p>The event handler can be bound to any <code>&lt;div&gt;</code>:</p>
<pre><code>$('#target').mouseup(function() {
alert('Handler for .mouseup() called.');
});
</code></pre>
<p>Now if we click on this element, the alert is displayed:</p>
<p>
<span class="output">Handler for .mouseup() called.</span>
</p>
<p>We can also trigger the event when a different element is clicked:</p>
<pre><code>$('#other').click(function() {
$('#target').mouseup();
});</code></pre>
<p>After this code executes, clicks on <span class="output">Trigger the handler</span> will also alert the message.</p>
<p>If the user clicks outside an element, drags onto it, and releases the button, this is still counted as a <code>mouseup</code> event. This sequence of actions is not treated as a button press in most user interfaces, so it is usually better to use the <code>click</code> event unless we know that the <code>mouseup</code> event is preferable for a particular situation.</p>
</longdesc>
<example>
<desc>Show texts when mouseup and mousedown event triggering.</desc>
<code><![CDATA[
$("p").mouseup(function(){
$(this).append('<span style="color:#F00;">Mouse up.</span>');
}).mousedown(function(){
$(this).append('<span style="color:#00F;">Mouse down.</span>');
});
]]></code>
<html><![CDATA[<p>Press mouse and release here.</p>
]]></html>
</example>
<category slug="events/mouse-events"/>
<category slug="version/1.0"/>
<category slug="version/1.4.3"/>
</entry>
Jump to Line
Something went wrong with that request. Please try again.