jQuery mouseup() 示例
jQuery 中的 mouseup() 方法用於觸發 mouseup 事件。該事件在所選元素上釋放滑鼠左鍵時發生。
語法
語法如下−
$(selector).mousedown(func)
上述 func 是 mouseup 事件觸發時要執行的函式。
示例
現在讓我們看一個實現 jQuery mouseup() 方法的示例−
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("h2").mouseup(function(){
$(this).after("<p>Mouse up (mouse button is released).</p>");
});
$("h2").mousedown(function(){
$(this).after("<p>Mouse down (mouse button is pressed down).</p>");
});
});
</script>
</head>
<body>
<h2>Press Here</h2>
</body>
</html>輸出
這將產生以下輸出−

按住並釋放滑鼠按鈕,將顯示以下內容−

示例
現在我們來看另一個示例−
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("h2").mouseup(function(){
alert("Mouse left released");
});
});
</script>
</head>
<body>
<h2>Press Here</h2>
</body>
</html>輸出
這將產生以下輸出−

按住並釋放滑鼠−

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP