Javascript 如何在jquery动画中使用-ms过滤器
我需要优化我的IE8网站。它不直接支持不透明度。可以使用-ms filter属性设置它。在我的javascript中,我使用jquery animate()更改不透明度。但是我如何使用-ms过滤器呢 现在我给你这个Javascript 如何在jquery动画中使用-ms过滤器,javascript,jquery,internet-explorer-8,Javascript,Jquery,Internet Explorer 8,我需要优化我的IE8网站。它不直接支持不透明度。可以使用-ms filter属性设置它。在我的javascript中,我使用jquery animate()更改不透明度。但是我如何使用-ms过滤器呢 现在我给你这个 $('.topbar img').animate({opacity:1, -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"},1500); 但是它抛出了一个JS错误。属性显然无效。有人能帮我如何在I
$('.topbar img').animate({opacity:1, -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"},1500);
但是它抛出了一个JS错误。属性显然无效。有人能帮我如何在IE8中制作动画吗。。?感谢您的帮助。尝试使用:
$('.topbar img').animate(
{
opacity:1,
'-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)'
// ^quotes
}
,1500);
实际上,使用jquery,您不应该需要-ms filter
属性。有关示例,请参见jQuery,它在动画的每个步骤中都会被触发
$('.topbar img').animate({
opacity: 1
},
{
step: function(now, fx) {
// Every step of the opacity animation we'll get the current
// opacity as the 'now' argument.
var opacity = Math.round(now * 100);
$(fx.elem).css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacity + ')');
}
});
可能重复:谢谢。。它起了部分作用。。。它改变了不透明度。但不是动画。谢谢你。