First, the basic grammar
1, Fadein fade in, fadeout fade out, Fadetoggle fade in and out (has faded out of the click Fade, or vice versa):
$ (selector). FadeIn (Duration,complete);
$ (selector). FadeOut (Duration,complete);
$ (selector). Fadetoggle (Duration,complete);
The optional speed parameter specifies the length of the effect. It can take the following values: "Slow" (200ms), "Fast" (600ms), or milliseconds. "Default is 400ms"
The optional callback parameter is the name of the function that is executed after fading completes.
2. The Fadeto:jquery FadeTo () method allows the gradient to be given opacity (values between 0 and 1).
$ (selector). FadeTo (Speed,opacity,callback);
The required speed parameter specifies the length of the effect. It can take the following values: "Slow", "fast", or milliseconds.
The required opacity parameter in the FadeTo () method sets the fade effect to the given opacity (values between 0 and 1).
The optional callback parameter is the function name that is executed after the function completes.
Ii. using Method 1, inline invocation (anonymous function)
<! DOCTYPE html>
The function is written directly at the callback.
2. External calls<! DOCTYPE html>Third, the new APIClick to refer to the new API parameters there are three, and the callback (complete) parameter is the last one, then why can it be executed correctly?
This is one of the JS features, have not seen such a function call before, and found that I did not pass the MyFunc function to the jquery function! This has to go into the bottom, so what is the so JS function?
Four, JS function overloading
The C-Series language learning experience all know that function passing parameters will be consistent check, you pass the number of parameters, the type of parameters will be checked. However, the above example shows that JavaScript does not have such a consistency check! It seems that he can accept more and less preaching. Verify that this is true, and pass a number of parameters.
Another problem is that it seems like the interval pass is OK?! This is a wonderful thing, so what is the reason? Thought for a long time did not want to understand! Look at the source code, found many jquery.extend methods, then determined: The reason is the function overload. but we notice the difference between JS and C + +, C + + will have parameter check, more than not, so you can directly define multiple parameter types or the number of different functions of the same name to implement overloading, JS but no matter how much you have, just ahead of the valid parameters. so how to implement JS function overload? there are many ways!
1, the use of arguments realization;
2, using typeof to determine the parameter type;
But these two methods have great limitations, if the parameters are many, overload logic is not very complex!? So is there a good way?
There's no good way to find out for the time being, but I've seen a few good articles
Make JavaScript easy to support function overloading
Http://vilic.info/blog/archives/tag/%E5%87%BD%E6%95%B0%E9%87%8D%E8%BD%BD
This article is organized by @the_third_wave (blog address: http://blog.csdn.net/zhanh1218). There are not covered, will be updated periodically, there are errors please correct me.
If you see this blog post is not complete, it is my first to prevent the crawler to release half of the reason, please see the original author blog.
If this blog post is helpful to you, for a good network environment, not recommended reprint, recommended collection! If you must reprint, please bring the suffix and the address of this document.
Effects of Fadein (), FadeOut (), Fadetoggle (), FadeTo () on the fade effect in jquery----about jquery function passing parameters