我只是想知道当jQuery不支持不透明度时,如何在IE浏览器中生成淡入淡出效果?动画不透明度是他们在Firefox和Chrome等其他浏览器中淡出的方式.
我进入了代码,但老实说,我找不到任何可以理解的东西!
我进入了代码,但老实说,我找不到任何可以理解的东西!
解决方法
从
jquery源,它们基本上检测是否支持不透明度,如果不支持,则使用IEs alpha过滤器
if ( !jQuery.support.opacity ) { jQuery.cssHooks.opacity = { get: function( elem,computed ) { // IE uses filters for opacity return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? ( parseFloat( RegExp.$1 ) / 100 ) + "" : computed ? "1" : ""; },set: function( elem,value ) { var style = elem.style,currentStyle = elem.currentStyle; // IE has trouble with opacity if it does not have layout // Force it by setting the zoom level style.zoom = 1; // Set the alpha filter to set the opacity var opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",filter = currentStyle && currentStyle.filter || style.filter || ""; style.filter = ralpha.test( filter ) ? filter.replace( ralpha,opacity ) : filter + " " + opacity; } }; }