1.

What are the jQuery functions used to provide effects?

Answer»

Some of the methods are listed below which provide the effect:

1. toggle() :


  • This function is used to check the visibility of selected elements to toggle between hide() and show() for the selected elements where:


    • show() is run when the element is hidden.


    • hide() is run when the element is visible.




  • Syntax: $(selector).toggle(speed, easing, callback)

2. slideDown() :


  • This function is used to either check the visibility of selected elements or to show the hidden elements. We can use this function on the following types of hidden elements:

    • Elements that are hidden using jQuery methods.

    • Elements that are hidden using display: none in the element’s CSS properties.




  • Syntax: $(selector).slideDown( speed, easing, callback )

3. fadeOut():


  • This function is used to change the level of opacity for element of choice from visible to hidden. When used, the fadded element will not occupy any space in DOM.


  • Syntax: $(selector).fadeOut( speed, easing, callback )

4. fadeToggle():


  • This is used for toggling between the fadeIn() and fadeOut() methods.

    • If elements are faded in state, fadeToggle() will fade out those elements.

    • If elements are faded out, fadeToggle() will fade in those elements.




  • Syntax: $(selector).fadeToggle(speed, easing, callback)

5. animate():


  • The method performs custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles.

  • The CSS property value is changed gradually, to create an animated effect.

  • Syntax: (selector).animate({styles},speed,easing,callback) where “styles” is a required field that specifies one or more CSS properties/values to animate. The properties need to be mentioned in camel casing style.

  • The parameters “speed”, “easing” and “callback” in the syntaxes of the above methods represent:


    • speed: Optional parameter and used for specifying the speed of the effect. The default value is 400 milliseconds. The possible value of speed are “slow”, “fast” or some number in milliseconds.


    • easing: Again optional parameter is used for specifying the speed of elements to different types of animation. The default value is “swing”. The possible value of easing are “swing” and “linear”.


    • callback: Optional parameter. The callback function specified here is executed after the effect method is completed.






Discussion

No Comment Found