开发者

How does jQuery .fadeTo() work?

开发者 https://www.devze.com 2023-04-03 23:11 出处:网络
I\'m curious how .fadeTo() fades an element? Does it use an i开发者_JAVA百科nline style of opacity to do this?

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);
},
0

精彩评论

暂无评论...
验证码 换一张
取 消