I'm curious how .fadeTo()
fades an element? Does it use an i开发者_JAVA百科nline style of opacity to do this?
And if it does not use css opacity, then how would you control css opacity using jQuery or javascript?
This question is referring to all of the following:
.fadeTo()
.fadeIn()
.fadeOut()
From the jQuery source - CSS opacity.
fadeTo: function( speed, to, easing, callback ) {
return this.filter(":hidden").css("opacity", 0).show().end()
.animate({opacity: to}, speed, easing, callback);
It does use CSS opacity!
Check out the source code here: http://code.jquery.com/jquery-latest.js
And search for fadeTo
.
You will see (as of today, anyway):
fadeTo: function( speed, to, easing, callback ) {
return this.filter(":hidden").css("opacity", 0).show().end()
.animate({opacity: to}, speed, easing, callback);
},
精彩评论