Thursday, April 30, 2009

[jQuery] Animate Variable Concatenate Help

I'm trying to get the width of an element, animate it bigger, then
shrink it back to normal size on hover. Here's my function:


$('a.slider').hover(function(){
var mywidth = $(this).width();
$(this).animate({width: "240px"});
}, function(){
$(this).animate({width: +mywidth+px"});
});


The line I'm having trouble with is:
$(this).animate({width: +mywidth+px"});

I know its not concatenated right, but I tried a few ways and couldn't
get it to work. What am I doing wrong? Thanks in advanced!

No comments: