为什么IE8不了解我的CSS

时间:2014-11-20 13:35:10

标签: jquery css internet-explorer-8

我有以下代码,我不明白错误是什么,IE8不喜欢它

var flap = $("#flap");
var animationSupport = _g.animationDetection();

if(animationSupport) {
    flap.addClass("showAnimation");
}
else {
    flap.css('width', flap.width() + 'px').css('right', '-' + flap.width() + 'px');
    flap.animate({right: 0}, 1500);
}

当我这样做时,我收到了消息:

Object doesn't support property or method 'width'

但是,如果我执行以下操作,似乎没问题:

$("#flap").css("width", "300px").css("right", "-300px");

2 个答案:

答案 0 :(得分:0)

我认为IE8可能不支持.width()。试试这个:

flap.css('width', flap.css('width')).css('right', '-' + flap.css('width'));

答案 1 :(得分:0)

请记住在正文和头部添加ie8支持代码

相关问题