tags:

views:

19

answers:

1

Let's say by using jQuery I can set the width of a DIV doing this:

$('#perc_in').width("14%");

then I make it do this:

$('#perc_in').width("57%");

Is there a way I can make it so instead of going from 14 to 57 I can make it SLIDE the progress bar from 14 to 57 percent? It's a simple div around another div with the percent being the progress (aka width).

+4  A: 

You can use .animate() to achieve that:

$('#perc_in').animate({'width': '57%'}, durationInMilliSeconds);
Raul Agrait
That's the basic idea (upvoted) but if you want to slide from left to right it's worth noting the div should be relative/absolute/floated left. Kind of like a progress bar feel. (For more information on this jquery function and easing visit: http://api.jquery.com/animate/)
Mahdi.Montgomery
OK Cool. Does this look good? $('#perc_in').animate({'width': result+'57%'}, 100);
Dan
result+'57%' - looks wrong to me. You'll want a number 1-100 with a percentage sign.. Maybe "result + '%'"?
Mahdi.Montgomery
Whoops I fixed it and it works! Thanks!
Dan