我正在使用具有多个句柄的JqueryUI范围滑块。当我开始滑动时如何获取句柄的jQuery对象?
示例:http://jqueryui.com/slider/#range
我试过..
$('#slider-range').slider({
range: true,
min: 10,
max: 180,
values: [ this.startDefaultVal, this.endDefaultVal ],
slide: function( event, ui ) { }
});
$('#slider-range').on( "slidestart", function( event, ui ) {
console.log(ui); // get the slide object which is being dragged
});
$('#slider-range').on( "slidestop", function( event, ui ) {
console.log(ui); // get the slide object which is being dragged
});
UI是一个完整的滑块对象,但在开始和停止时我想知道我实际拖动的两个滑块中的哪一个?
答案 0 :(得分:2)
从docs引用。
ui
Type: Object
handle
Type: jQuery
The jQuery object representing the handle being moved.
所以你应该能够使用ui.handle来获取一个常规的jQuery对象并读取它的id / class /...
$('#slider-range').on( "slidestop", function( event, ui ) {
ui.handle // the slide jQuery object
});
答案 1 :(得分:2)
ui.handle
应该为您提供拖动的句柄
$('#slider-range').on( "slidestart", function( event, ui ) {
console.log('s',ui.handle); // get the slide object which is being dragged
});
演示:Plunker