Tommy Brunn
Tommy Brunn

Reputation: 2562

IE8 'Invalid argument' in small jQuery animate snippet

I've got a list where every time an item is added, the last item should be removed. I've got it working fine in Chrome and Firefox, but IE refuses.

Not sure why, but IE8 throws an Invalid argument error at some point. I believe I have tracked it down to this portion, but I don't know where or why. Just in case the error is actually outside this portion, you can see a more complete, working (or not working in IE8) version here.

first.animate({top:0}, 250, function() {
    first.animate({marginTop: oldMarginTop}, 500, function() {
        last.animate({top: olPaddingBottom}, 125, function() {
            //Remove the old element
            last.remove();
            //Reset the CSS we changed
            stream.css({
                height: 'auto',
                overflowY: 'visible'
            });
        });
    });
});

first and last are selected nodes from the list. First is the newly created list item, and last is the one we will be removing.

Upvotes: 1

Views: 757

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117354

use instead of oldMarginTop....

parseInt(0+oldMarginTop,10)

for me IE returns "auto" for oldMarginTop , this value cannot be animated, you need a numeric value( the suggestion will set the value to 0 when it is not a numeric value)

http://jsbin.com/uvepit/

Upvotes: 2

Related Questions