HTML事件属性ondblclick

2018-01-05 13:58 更新

HTML事件属性ondblclick


触发 ondblclick 属性事件当双击元素上的鼠标按钮。

HTML5中的新功能

没有。

句法

<element ondblclick="script or Javascript function name">

支持的标签

所有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



实施例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

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号