The first time around increment is 10, like it should be, the second iteration returns undefined. I assume that it has got something to do with setTimeout?
var time = 200;
Function:
function repeatingfunction(increment) {
if (time>5){
time=time-39
};
if (mausunten == true){
//alert(increment);
setTimeout(repeatingfunction, time);
$("#slider-vertical").slider("value", ($("#slider-vertical").slider("value"))+increment);
refreshCalculation();
};
if (mausunten == false){
clearTimeout(repeatingfunction);
};
}
Calling and stopping the function:
$("#plus1").mousedown(function(){
mausunten = true;
repeatingfunction(10);
});
$(document).mouseup(function() {
mausunten = false;
time = 200;
});