The ondblclick
attribute event is triggered
when double clicking a mouse button on the element.
None.
<element ondblclick="script or Javascript function name">
All HTML elements, EXCEPT:
<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, <title>
ondblclick |
Yes | Yes | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<!-- ww w. j a va 2s. c o m-->
<button ondblclick="myFunction()">Double-click me</button>
<script>
function myFunction() {
console.log("Hello World");
}
</script>
</body>
</html>
The following code shows how to handle double click event in Javascript.
<html>
<head>
<script language="JavaScript">
function addunderline() {<!-- w w w . ja v a2s. co m-->
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>