Is there a jQuery/JavaScript function to adjust a range of <0 to 500> to <0 to 1> -
i'm trying copy effect of jquery slider using position of pointer on div. range 0 500 , adjust 0 1 opacity there jquery function adjust ranges this?
$('#old').mousemove( function(e){ var parentoffset = $(this).parent().offset(); var mousex = e.pagex - parentoffset.left; var mousey = 500-(e.pagey - parentoffset.top); $('#position').html(mousex+" "+mousey); $('#old').css('opacity', '.'+mousey); }); '.'+mousey decimal there result working.
simply divide returned value 500 value between 0 , 1.
$('#old').css('opacity', (mousey/500));
Comments
Post a Comment