I have an HTML5 \'range\' control to which I want to add a plus (+) and minus (-) buttons on either sides.
The fiddle works fine, except that the value increase (or
Edit, Updated
Try
var range = $("#range")
, fx = function(elem, prop) {
return elem
.animate({
value: range.prop(prop)
}, {
duration: 3000,
easing: "linear",
step: function(now) {
elem.val(now + prop === ("max","+"||"min","-") + elem.prop("step"))
}
})
};
$('#plus').mousedown(function(e) {
fx(range, "max")
});
$('#minus').mousedown(function minus(e) {
fx(range, "min")
});
$(document).mouseup(function(e) {
range.stop(true, false)
});
jsfiddle http://jsfiddle.net/bnesu3h9/3/
var range = $("#range")
, fx = function(elem, prop) {
return elem
.animate({
value: range.prop(prop)
}, {
duration: 3000,
easing: "linear",
step: function(now) {
elem.val(now + prop === ("max","+"||"min","-") + elem.prop("step"))
}
})
};
$('#plus').mousedown(function(e) {
fx(range, "max")
});
$('#minus').mousedown(function minus(e) {
fx(range, "min")
});
$(document).mouseup(function(e) {
range.stop(true, false)
});
#plus {
width: 15px;
height: 15px;
background-color: red;
float: left;
}
#minus {
width: 15px;
height: 15px;
background-color: blue;
float: left;
}
.range-container {
float: left;
overflow: auto;
}