这可以非常简单地完成:
http://jsfiddle.net/IonDen/z8j5anno/
var $range = $(".js-range-slider");
var label;
function Label (container) {
this.$label = $(container).find(".irs-single");
this.active = false;
this.ACTIVE = "irs-single--active";
}
Label.prototype = {
start: function () {
if (!this.active) {
this.active = true;
this.$label.addClass(this.ACTIVE);
}
},
end: function () {
this.$label.removeClass(this.ACTIVE);
this.active = false;
}
};
$range.ionRangeSlider({
type: "single",
min: 0,
max: 1000,
from: 500,
grid: true,
onStart: function (data) {
label = new Label(data.slider);
},
onChange: function () {
label.start();
},
onFinish: function () {
label.end();
}
});