admin管理员组

文章数量:1279118

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;
    }
);

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;
    }
);
Share Improve this question edited Aug 5, 2010 at 16:33 Ken Redler 23.9k8 gold badges59 silver badges69 bronze badges asked Aug 5, 2010 at 16:25 sea_1987sea_1987 2,95412 gold badges46 silver badges69 bronze badges 1
  • IE6 just loads with errors on page – sea_1987 Commented Aug 5, 2010 at 16:27
Add a ment  | 

3 Answers 3

Reset to default 11

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

$('#login').animate({
  marginTop: '0' //No ma, can you see it?
}, 1000);

Yes, I guess I can.

The EVIL COMMA has GOT you !!

marginTop: '0',  // remove ma

and

marginTop: '-280', // remove ma

Trailing mas are a big NoNo in IE's.

Also shouldn't it be

"-280px" // added "px"

本文标签: javascriptjQuery crossbrowser issueStack Overflow