Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JQUERY Animate width using variable

Status
Not open for further replies.

GOSCO

Technical User
Sep 26, 2000
134
GB
Good evening,

Please can someone help me with this code? I'm just trying to animate the width of a progress bar based on a variable, the code works fine if I write this: $(this).animate({width:"100px"},350); so I think it is just a syntax problem but I can't for the life of me figure it out!


Code:
$("div.progressBarValue").each(function(){
    var a= $( this ).css( "width" );
    $(this).animate({width:a},350);
});

Thanks in advance
 
I think I made a silly mistake:

I set width 0 first and then animated:

Code:
    $(this).css("width", "0");

now it works :)
 
good job. made it work after all.


but 'making it work' and understanding why what you did, made it work is the difference between a hacker and a programmer :)

im in between the two tbh heh

lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top