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.

http://jsfiddle.net/chrisloughnane/ddsrq/

simply divide returned value 500 value between 0 , 1.

$('#old').css('opacity', (mousey/500)); 

http://jsfiddle.net/ddsrq/2/


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -