模拟“点击并按住5秒钟" jQuery上的元素 [英] simulate a "click and hold for 5 sec" on element with jquery

查看:131
本文介绍了模拟“点击并按住5秒钟" jQuery上的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用活动"选择器对元素进行了一些CSS3转换.我现在需要的是在页面加载时对该元素的单击并保持4-5秒"行为进行编程,而无需用户实际单击它.

I have done some CSS3 transitions on an element, using the "active" selector. What I need now is to program the "click and hold for 4-5 sec" behavior on that element, when the page loads, without having the user to actually click on it.

是否可以使用jQuery或javascript在特定的时间内模拟单击并按住"?

Is there a way to simulate the "click and hold" for a specific amount of time, either with jQuery or javascript?

类似

$('div').click(5000);

显然不起作用.

谢谢!

推荐答案

如果您坚持必须使用JQuery模拟它,则mousedown事件应该起作用.像这样:

If you insist on having to simulate it with JQuery, mousedown event should work. Something like this:

$('div').mousedown(function(){
    setTimeout(function(){ $('div').mouseup(); }, 5000);
});

祝你好运.

这篇关于模拟“点击并按住5秒钟" jQuery上的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆