HTML事件屬性ondblclick
HTML事件屬性ondblclick
觸發(fā)ondblclick
屬性事件當(dāng)雙擊元素上的鼠標(biāo)按鈕。
HTML5中的新功能
沒(méi)有。
句法
<element ondblclick="script or Javascript function name">
支持的標(biāo)簽
所有HTML元素,EXCEPT:
<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, <title>
瀏覽器兼容性
ondblclick | Yes | Yes | Yes | Yes | Yes |
例子
<!DOCTYPE html>
<html>
<body>
<button ondblclick="myFunction()">Double-click me</button>
<script>
function myFunction() {
console.log("Hello World");
}
</script>
</body>
</html>
Click to view the demo
實(shí)施例2
下面的代碼顯示了如何在Javascript中處理雙擊事件。
<html>
<head>
<script language="JavaScript">
function addunderline() {
head1.style.textDecoration = "underline"
}
function removeunderline() {
head1.style.textDecoration = "none"
}
function addoverline() {
head1.style.textDecoration = "overline"
}
function addlinethrough() {
head1.style.textDecoration = "line-through"
}
</script>
</head>
<body>
<h1 id="head1"
onMouseover="addunderline()"
onMouseout="removeunderline()"
onClick="addoverline()"
ondblclick="addlinethrough()">Welcome to this page!</h1>
<P>A lot of interesting text goes here!</p>
</body>
</html>
Click to view the demo