开发者

How to get value of the slider, when touchend or mouseup events are used?

$('.ui-slider-handle').live('touchend', function(){
// how can I get slider's value here?
});

$('.ui-slider-handle').live('mouseup', function(){
// and here?
});

I don't want t开发者_StackOverflowo use .change since it is called even when sliders are moving.


You could just use the event stop
http://jqueryui.com/demos/slider/#event-stop


Well, it's fairly simple to get the current value of a slider:

$('.ui-slider-handle').live('mouseup', function() {
  var value = $(this).closest('.ui-slider').slider('value');
});

You'll have to experiment with this though, because I've found that often this is not the most-up-to-date value (it's usually one click less than the actual final value).

What you REALLY want to do is use the slidestop event built-in to the slider widget, but of course right now it is not supporting touchend for some reason. (Along with a few other issues on touch devices.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜