jquery-mobile/experiments/api-viewer/docs/mouseup/index.html
scottjehl c7fae44a5c added a jQuery api viewer demo.
NOTE: content is a modified version of the downloadable HTML from http://jqapi.com
2010-09-16 13:13:38 -04:00

78 lines
No EOL
3.5 KiB
HTML

<!DOCTYPE html>
<html lang='en'><head><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
<div class="ui-page">
<div class="ui-header">
<h1>.mouseup()</h1>
</div>
<div class="ui-content ui-body ui-body-c" id="mouseup1">
<h2 class="jq-clearfix roundTop section-title">
<span class="name">.mouseup( handler(eventObject) )</span> <span class="returns">Returns: <a class="return" href="http://docs.jquery.com/Types#jQuery">jQuery</a></span>
</h2>
<div class=" entry-details">
<p class="desc"><strong>Description: </strong>Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element.</p>
<ul class="signatures">
<li class="signature" id="mouseup-handlereventObject">
<h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.0/">1.0</a></span>.mouseup( handler(eventObject) )</h4>
<p class="arguement"><strong>handler(eventObject)</strong>A function to execute each time the event is triggered.</p>
</li>
<li class="signature" id="mouseup"><h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.0/">1.0</a></span>.mouseup()</h4></li>
</ul>
<div class="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>&lt;div id="target"&gt;
Click here
&lt;/div&gt;
&lt;div id="other"&gt;
Trigger the handler
&lt;/div&gt;
</pre>
<p class="image"><img src="http://api.jquery.com/images/0042_05_02.png" alt=""></p>
<p>The event handler can be bound to any <code>&lt;div&gt;</code>:</p>
<pre>$('#target').mouseup(function() {
alert('Handler for .mouseup() called.');
});
</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>$('#other').click(function() {
$('#target').mouseup();
});</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>
</div>
<h3>Example:</h3>
<div id="entry-examples" class="entry-examples"><div id="example-0">
<h4><span class="desc">Show texts when mouseup and mousedown event triggering.</span></h4>
<pre><code class="example demo-code">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Press mouse and release here.&lt;/p&gt;
&lt;script&gt;
$("p").mouseup(function(){
$(this).append('&lt;span style="color:#F00;"&gt;Mouse up.&lt;/span&gt;');
}).mousedown(function(){
$(this).append('&lt;span style="color:#00F;"&gt;Mouse down.&lt;/span&gt;');
});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div></div>
</div>
</div>
</div>
</body></html>