mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-18 15:00:23 +00:00
78 lines
No EOL
3.5 KiB
HTML
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 data-role="page">
|
|
<div data-role="header">
|
|
<h1>.mouseup()</h1>
|
|
|
|
</div>
|
|
<div data-role="content" class=" 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><div id="target">
|
|
Click here
|
|
</div>
|
|
<div id="other">
|
|
Trigger the handler
|
|
</div>
|
|
</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><div></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"><!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
|
</head>
|
|
<body>
|
|
<p>Press mouse and release here.</p>
|
|
|
|
<script>
|
|
$("p").mouseup(function(){
|
|
$(this).append('<span style="color:#F00;">Mouse up.</span>');
|
|
}).mousedown(function(){
|
|
$(this).append('<span style="color:#00F;">Mouse down.</span>');
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html></code></pre>
|
|
<h4>Demo:</h4>
|
|
<div class="demo code-demo"></div>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html> |