如何检查jquery.ui.touch-punch的滑块是否被触摸

How to check if slider of jquery.ui.touch-punch is touched?

本文关键字:是否 触摸 touch-punch ui 何检查 检查 jquery      更新时间:2023-09-26

我正在使用http://touchpunch.furf.com/以实现对移动滑块ans的触摸,该滑块工作得非常好。只是我希望能够在触摸滑块时显示滑块的当前值。

LIBARY
<!--slider event starts-->
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js"></script>
<script src="../scripts/jquery.ui.touch-punch.min.js"></script>
<script>$('#slider_small').draggable();</script>
<!--slider event ends-->

在桌面上,我使用鼠标移动,但在移动设备上,我不知道该用什么:

$("#slider").mousemove( function(e){
        $("#valBox").html($(this).val());
});

我试过了,点击"tap"、"ontouchstart"、可拖动、"mousedown"。有人能帮我做这个吗?

$("#slider_small").bind("touchmove", function() { 
        $("#valBox_small").html($(this).val());
});

您可以尝试jQuery提供的虚拟鼠标事件。

尝试以下代码

$( document ).on( "vmousedown", "#slider_small", function() {
   $("#valBox_small").html($(this).val());
});

请参阅此处的文档