简体   繁体   中英

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

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

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.

也不应该

"-280px" // added "px"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM