开发者

How does jQuery .fadeTo() work?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜