Home  >  Article  >  Web Front-end  >  The event attribute onmouseup triggered when the mouse button is released in html

The event attribute onmouseup triggered when the mouse button is released in html

黄舟
黄舟Original
2017-11-06 11:32:383353browse

Example

Execute JavaScript when releasing the mouse button on the paragraph:

<p onmouseup="mouseUp()">Click the text!</p>

Browser support


IE

Firefox

Chrome

Safari

Opera


All major browsers support the onmouseup attribute.

Definition and Usage

The onmouseup attribute is triggered when the mouse button is released.

Tip: Event order relative to onmouseup event (limited to left/middle mouse button):

  1. onmousedown

  2. onmouseup

  3. onclick

The event sequence of the onmouseup event (limited to the right mouse button):

  1. onmousedown

  2. onmouseup

  3. oncontextmenu

Note: The onmouseup attribute does not apply to the following elements: fc7239c59b5522dc8489367176cf4a7b, 0c6dc11e160d3b678d68754cc175188a, 93f0f5c25f18dab9d176bd4f6de5d30e, 100db36a723c770d327fc0aef2ce13b1, d5ba1642137c3f32f4f4493ae923989c, e8e496c15ba93d81f6ea4fe5f55a2244, 0c68fef83818661b6da588c77ca3985e, 3f1c4e4b6b16bbbd69b2ee476dc4f83a, c9ccee2e6ea535a969eb3f532ad9fe89 or

Differences between HTML 4.01 and HTML5

None.

Syntax

<element onmouseup="script">

Attribute value

Value Description
script Script to run when onmouseup occurs.

Their implementation is by calling javaScript scripts. What we can also see in this program is the processing of text color. Our process of processing text color is

getElementById().style.color to set the color of the text

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript">
         function mouseDown()
         {
            document.getElementById("p1").style.color="red";


         }
         function mouseUp()
         {
        document.getElementById("p1").style.color="green";
          }
     </script>
<title>鼠标事件</title>
</head>
<body>
<p id="p1" onmousedown="mouseDown()" onmouseup="mouseUp()">点击文本</p>
当鼠标按下的时候触发mouseDown()函数,该函数是将文本样式变成红色
当鼠标松开的是触发mouseUp()函数,该函数将文本的样式变成绿色
</body>
</html>
<!-- 在这个程序中我们不仅仅应该知道的是鼠标事件,也就是onmousedown
和onmouseup这两个事件,而且他们发生的时候会调用函数
我们还应该知道是怎样来改变字体的颜色,在这个程序中我们改变字体的颜色是doucment根据id获取元素,并且定义样式然后是颜色,
在HTML中我们可以看到设置的过程中分好多的等级。元素分为样式,还有value,样式有颜色这样的等级的划分 -->

The above is the detailed content of The event attribute onmouseup triggered when the mouse button is released in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn