I am working on a project in which i want a menu to appear on screen whenever it is touched and hold. So I want to know that just like button click and hover property in CSS is there any way to implement click and hold property, if no then how it can be done using javascript or jquery.
我正在开展一个项目,在这个项目中我想要一个菜单在触摸和保持时出现在屏幕上。所以我想知道,就像CSS中的按钮点击和悬停属性有任何方法来实现点击和保持属性,如果没有,那么如何使用javascript或jquery完成。
thanks
2 个解决方案
#1
1
You can do this using jQuery, a combination of mousedown
, mouseup
and mouseleave
你可以使用jQuery,mousedown,mouseup和mouseleave的组合来做到这一点
<button class="testHold">click and hold me</button>
<div class="tracker"></div>
$('.testHold').mousedown(function() {
$('.tracker').html("holding holding holding");
}).bind('mouseup mouseleave', function() {
$('.tracker').text('free as a bird...');
});
#2
0
There is no truly native way to accomplish this. You can check out this solution for a good workaround using jquery's draggable plugin.
没有真正的本土方式来实现这一目标。您可以使用jquery的draggable插件查看此解决方案以获得良好的解决方法。
触发点击并保持事件
#1
1
You can do this using jQuery, a combination of mousedown
, mouseup
and mouseleave
你可以使用jQuery,mousedown,mouseup和mouseleave的组合来做到这一点
<button class="testHold">click and hold me</button>
<div class="tracker"></div>
$('.testHold').mousedown(function() {
$('.tracker').html("holding holding holding");
}).bind('mouseup mouseleave', function() {
$('.tracker').text('free as a bird...');
});
#2
0
There is no truly native way to accomplish this. You can check out this solution for a good workaround using jquery's draggable plugin.
没有真正的本土方式来实现这一目标。您可以使用jquery的draggable插件查看此解决方案以获得良好的解决方法。
触发点击并保持事件