I tried that initially. It didn't work. I think my variable isn't
being recognized by the second half of my function. I get this error
in firebug.. "mywidth is not defined". But if I alert it in the upper
half I get a value.




On Apr 30, 2:15 pm, pete higgins <phigg...@gmail.com> wrote:
> $(this).animate({ width: mywidth + "px" });
>
> think:
>
> var newwidth = {
>    "width": mywidth + "px"
>
> }
>
> Regards
>
> On Thu, Apr 30, 2009 at 5:54 PM, paper_robots <mresto...@gmail.com> wrote:
>
> > 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!

Reply via email to