JavaScript onmouseup 事件

來源:互聯網
上載者:User
Definition and Usage
定義與用法

The onmouseup event occurs when a mouse button is released.
當滑鼠按鍵鬆開時觸發onmouseup事件

Syntax
文法
onmouseup="所要執行的代碼"

Parameter
參數
Description
注釋
SomeJavaScriptCode
所要執行的代碼
Required. Specifies a JavaScript to be executed when the event occurs.
必選項。當時間觸發時所要執行的代碼

Supported by the following HTML tags:
所支援的HTML標籤:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:
所支援的JavaScript對象:

button, document, link

Example 1
執行個體1

In this example an alert box is displayed when the mouse button is released after clicking the picture:
在下面的例子中,當你點擊圖片並鬆開滑鼠時將彈出一個訊息框:

<img src="image_w3default.gif" 
onmouseup="alert('你點擊過圖片')">

The output of the code above will be (click on the picture):
上述代碼的輸出結果為:

Example 2
執行個體2

In this example an alert box will alert the tag name of the element you clicked on:
在下面的例子中,彈出的訊息框將顯示你所點擊過的元素名稱:

<html>
<head>
<script type="text/javascript">
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode
var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element.")
}
</script>
</head>
<body onmouseup="whichElement(event)">
<h2>This is a header</h2>
<p>This is a paragraph</p>
<img border="0" src="ball16.gif" alt="Ball">
</body>
</html>

Try-It-Yourself Demos
互動式示範

onmouseup
How to use onmouseup to display an alert box when an image is clicked.
如何應用onmouseup事件在點擊一張圖片後彈出訊息框

onmouseup 2
How to use onmouseup to alert the tag name of the element you clicked on.
如何應用onmouseup事件和訊息框顯示你所點擊的元素名稱。
轉載 http://www.w3pop.com/tech/school/jsref/jsref_onmouseup.asp

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.