9951 explained code solutions for 126 technologies


jqueryHow do I use jQuery to fade out an element?


Using jQuery, you can easily fade out an element using the fadeOut() method. This method takes an optional parameter of the fade duration in milliseconds. Here is an example of using the fadeOut() method:

$('.element').fadeOut(1000);

This will fade out the element with the class element over a duration of 1000 milliseconds (1 second).

Parts of the code:

  1. $('.element'): This is the jQuery selector which is used to select the element with the class element.
  2. fadeOut(1000): This is the fadeOut() method which is used to fade out the selected element. The parameter 1000 is used to set the duration of the fade in milliseconds.

Helpful links

Edit this code on GitHub