Element: dblclick event - Web APIs 编辑
The dblclick
event fires when a pointing device button (such as a mouse's primary button) is double-clicked; that is, when it's rapidly clicked twice on a single element within a very short span of time.
dblclick
fires after two click
events (and by extension, after two pairs of mousedown
and mouseup
events).
Bubbles | Yes |
---|---|
Cancelable | Yes |
Interface | MouseEvent |
Event handler property | ondblclick |
Examples
This example toggles the size of a card when you double click on it.
JavaScript
const card = document.querySelector('aside');
card.addEventListener('dblclick', function (e) {
card.classList.toggle('large');
});
HTML
<aside>
<h3>My Card</h3>
<p>Double click to resize this object.</p>
</aside>
CSS
aside {
background: #fe9;
border-radius: 1em;
display: inline-block;
padding: 1em;
transform: scale(.9);
transform-origin: 0 0;
transition: transform .6s;
user-select: none;
}
.large {
transform: scale(1.3);
}
Result
Specifications
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论