How do jQuery fade in IE8 and below?

I just wanted to know how jQuery can generate a fading effect in IE browsers when they don't support opacity ? An opacity animation is the way they fade out in other browsers like Firefox and Chrome. I entered the code, but to be honest, I could not find anything clear to me!

+6
source share
2 answers

From a jquery source, they mostly detect if opacity is supported, and if not, use IE alpha filter

 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; } }; } 
+9
source

using the following filter:alpha(opacity=40) style filter:alpha(opacity=40)

+3
source

Source: https://habr.com/ru/post/894669/


All Articles