[英]is it possible fire an event on button press and hold in css?
我正在一个项目中,希望在触摸并按住菜单时将其显示在屏幕上。 因此,我想知道,就像CSS中的按钮单击和悬停属性一样,有任何方法可以实现单击并保留属性,如果没有,那么如何使用javascript或jquery来实现。
谢谢
您可以使用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...');
});
没有真正的本机方法可以做到这一点。 您可以使用jquery的Draggable插件来查看该解决方案,以获得一个好的解决方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.