Examples of common jquery effects methods are used
- 2020-03-30 02:45:53
- OfStack
1. JQuery fadeIn() is used to fadeIn hidden elements.
Grammar:
$(selector).fadeIn(speed,callback);
Example:
$("button").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
2. The jQuery fadeOut() method is used to fadeOut visible elements.
Grammar:
$(selector).fadeOut(speed,callback);
3. The jQuery fadeToggle() method can switch between fadeIn() and fadeOut() methods.
If the element fades out, fadeToggle() adds a fadein effect to the element.
If the element fades in, fadeToggle() adds a fadeout effect to the element.
Grammar:
$(selector).fadeToggle(speed,callback);
Example: $("button").click(function(){
$("#div1").fadeToggle();
$("#div2").fadeToggle("slow");
$("#div3").fadeToggle(3000);
});
4). Grammar:
$(the selector). FadeTo (speed, opacity, callback);
The required speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
FadeTo () method of the necessary opacity parameter sets the fading effect to the given the opacity (value between 0 and 1). The instance
$("button").click(function(){
$("#div1").fadeTo("slow",0.15);
$("#div2").fadeTo("slow",0.4);
$("#div3").fadeTo("slow",0.7);
});
5. The jQuery slideDown() method is used to slideDown elements.
Grammar:
$(selector).slideDown(speed,callback);
$("#flip").click(function(){
$("#panel").slideDown();
});
6. The jQuery slideUp() method is used to slide elements up.
Grammar:
$(selector).slideUp(speed,callback);
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of the function to be executed after the slide completes.
7. The jQuery slideToggle() method can be switched between the slideDown() and slideUp() methods.
If elements slide down, slideToggle() slides them up.
If elements slide up, slideToggle() slides them down.
$(selector).slideToggle(speed,callback);
The jQuery animate() method is used to create custom animations.
Grammar:
$(selector).animate({params},speed,callback);
The required params parameters define the CSS properties that form the animation.
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of the function to be executed after the animation is completed.
You can also define a relative value (the value relative to the current value of the element). The value needs to be preceded by += or -= :
You can also define a set of animate to implement the queue function.
The following example illustrates a simple application of the animate() method; It < Div> Move the element to the left until the left attribute equals 250 pixels:
The instance
$("button").click(function(){
$("div").animate({left:'250px'});
});
The jQuery stop() method is used to stop animations or effects until they are complete
10. When the animation is 100% complete, the Callback function is called.
Typical syntax:
$(selector).hide(speed,callback)
JQuery method links
Some elements only need to be fetched once, so you can append methods with links.
Method dot method. Such as
$("#p1").css("color","red").slideUp(2000).slideDown(2000);