javascript
JavaScript onmouseup 事件
Definition and Usage
定義與用法
The onmouseup event occurs when a mouse button is released.
當鼠標按鍵松開時觸發(fā)onmouseup事件
Syntax
語法
| οnmοuseup="所要執(zhí)行的代碼" |
| SomeJavaScriptCode 所要執(zhí)行的代碼 | Required. Specifies a JavaScript to be executed when the event occurs. 必選項。當時間觸發(fā)時所要執(zhí)行的代碼 |
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" οnmοuseup="alert('你點擊過圖片')"> |
The output of the code above will be (click on the picture):
上述代碼的輸出結(jié)果為:
Example 2
實例2
In this example an alert box will alert the tag name of the element you clicked on:
在下面的例子中,彈出的消息框?qū)@示你所點擊過的元素名稱:
| <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 οnmοuseup="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事件和消息框顯示你所點擊的元素名稱。
轉(zhuǎn)載 http://www.w3pop.com/tech/school/jsref/jsref_onmouseup.asp
轉(zhuǎn)載于:https://www.cnblogs.com/yzxchoice/archive/2007/01/10/616463.html
總結(jié)
以上是生活随笔為你收集整理的JavaScript onmouseup 事件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#中通过代码控制IIS服务重启
- 下一篇: 机器学习基石-作业四-代码部分