jquery双击修改_jQuery双击

jquery双击修改

jQuery dblclick() function fires when an HTML element is double clicked. This method will attach an event handler to the double click event. We can do desired manipulations on the selected HTML element using the jQuery double click event handler.

双击HTML元素时,将触发jQuery dblclick()函数。 此方法会将事件处理程序附加到双击事件。 我们可以使用jQuery双击事件处理程序对选定HTML元素进行所需的操作。

jQuery双击 (jQuery double click)

jQuery double click event syntax:

jQuery双击事件语法:

  • dblclick()

    dblclick()

In this, dblclick() method is used without an argument.

在这种情况下,使用dblclick()方法时不带参数。

  • dblclick(handler)

    dblclick(处理程序)

The handler could be any function that is executed each time the double click event is fired.

该处理程序可以是每次触发双击事件时执行的任何函数。

jQuery双击示例 (jQuery Double Click Example)

Following example demonstrates the use of jQuery dblclick() event method.

以下示例演示了jQuery dblclick()事件方法的使用。

<!DOCTYPE html>
<html>
<head>
<title>jQuery Double Click</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script> 
$(document).ready(function(){
  $("div").dblclick(function(){
    $( this ).toggleClass("divClass2");
  });
});
</script>
 
<style> 
.divClass1
{
    padding:5px;
    text-align:center;
    background-color:yellow;
    border:solid 1px;
}
.divClass2
{
    padding:5px;
    text-align:center;
    background-color:grey;
    border:solid 1px;
}
</style>
</head>
<body>
<div class="divClass1">JournalDev</div>
</body>
</html>

In this example, you can see that dblclick() method is triggered when you double click on the <div> element.

在此示例中,您可以看到双击<div>元素时触发了dblclick()方法。

In this method, we pass a handler to change the background color of the <div> element.

在此方法中,我们传递了一个处理程序来更改<div>元素的背景颜色。

The toggleClass() method toggle between the two CSS class defined in the above code. The toggleClass() method executes each time when we double click on the element.

toggleClass()方法在上述代码中定义的两个CSS类之间切换。 每次双击元素时,都会执行toggleClass()方法。

You can see above jQuery example in action by visiting below URL.

您可以通过访问下面的URL来查看上面的jQuery示例的运行情况。

jQuery双击演示 (jQuery Double Click Demo)

翻译自: https://www.journaldev.com/4947/jquery-double-click

jquery双击修改

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值