Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery cross-browser issue

I have this code that works great in all browsers but not IE6, and I have no idea why, can anyone shed any light on this?

$("#handle").toggle(    
    function () {
        $('#login').animate({
            marginTop: '0',
        }, 1000);
        $("#handle").addClass('opened');
        return false;
    }, 
    function () {
        $('#login').animate({
            marginTop: '-280',
        }, 1000);
        $("#handle").removeClass('opened');
        return false;
    }
);
like image 249
sea_1987 Avatar asked Aug 05 '10 16:08

sea_1987


2 Answers

You have trailing commas in the object literals passed to animate(). IE does not support this. This should work:

$('#login').animate({
  marginTop: '0' //No comma, can you see it?
}, 1000);
like image 102
MooGoo Avatar answered Oct 20 '22 02:10

MooGoo


Yes, I guess I can.

The EVIL COMMA has GOT you !!

marginTop: '0',  // remove comma

and

marginTop: '-280', // remove comma

Trailing commas are a big NoNo in IE's.

like image 23
jAndy Avatar answered Oct 20 '22 02:10

jAndy