I have this script that allows you to increase / decrease the value of an input by dragging up and down with the click pressed. But I need to make it work to be able to add this functionality to any input also with a minimum and a maximum value range link
var clicking = false;
$('this').click(function () {
clicking = false;
});
$('#change_value_up_down').mousedown(function () {
clicking = true;
});
var i = 0;
var y = 0;
$(this).mousemove(function(my){
if(clicking === false)
{
return false;
}
else
{
// change value
if (my.pageY <= $('#change_value_up_down').offset().top + $('#change_value_up_down').css('width').replace('px', '')/10)
{
y = parseInt($('#change_value_up_down').val()) +1 ;
$('.movestatus').text('plus');
}
else
{
y = parseInt($('#change_value_up_down').val()) -1;
$('.movestatus').text('minus');
}
$('#change_value_up_down').val(parseInt(y));
// Mouse click + moving logic here
//$('.movestatus').text('mouse moved ' + i);
i++;
}
});
$(this).mouseup(function(e) {
clicking = false;
//e.stopPropagation();
});
$('.selector').mouseup(function(e) {
i = 0;
});
The code is raw, but I need this to be a function to do it in any input.