HTML onmouseup 事件屬性


HTML onmouseup 事件屬性在 HTML 文件中的 HTML 元素中釋放滑鼠按鈕時觸發。

語法

語法如下 −

<tagname onmouseup=”script”></tagname>

讓我們看一個 HTML onmouseup 事件屬性的示例 −

示例

 現場演示

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      color: #000;
      height: 100vh;
      background-color: #FBAB7E;
      background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
      text-align: center;
   }
   .circle {
      background: #db133a;
      height: 150px;
      width: 150px;
      border-radius: 50%;
      margin: 10px auto;
   }
   p {
      margin: 30px auto;
   }
</style>
</head>
<body>
<h1>HTML onmouseup Event Attribute Demo</h1>
<div class="circle" onmousedown="mouseDownFn()" onmouseup="mouseUpFn()"></div>
<p>Try to click the above red circle</p>
<script>
   function mouseDownFn() {
      document.querySelector('.circle').style.transform = 'scale(0.5)';
   }
   function mouseUpFn() {
      document.querySelector('.circle').style.transform = 'scale(1.2)';
   }
</script>
</body>
</html>

輸出

單擊“紅色”圓圈來觀察 onmouseup 事件屬性如何工作。


更新於: 27-9-2019

97 瀏覽次數

開啟你的 職業生涯

完成課程認證

開始
廣告