jQuery fadeTo() Method

jQuery fadeTo() method perform fades in/out effect on the selected elements to a given opacity.


This syntax represent to the fadeTo method

$(selector).fadeTo( duration, opacity, easing, callback );
Parameter Type Description
duration Number
Required. Accept string or number that determining how long fading effect will run.
default value is 400
Accepted values:
  • Predefined duration ("slow", "normal", "fast")
  • number of milliseconds (3000, 1000)
opacity Number Required. Specifies the opacity value between 0 and 1.
easing String Optional. Specifies the which easing function to use for the transition.
default value is "swing"
Accepted values:
  • "swing" - elements moves slows at the starting and ending, but faster in the middle
  • "linear" - elements moves in a constant speed
callback Function Optional. A function to call once the fadeTo is complete.


Here, in this example show fadeTo effect on selected elements when click on button.

<!DOCTYPE html>
  <title>jQuery fadeTo() method</title>
  <script src="jquery-latest.min.js"></script>
    $(document).ready(function() {
        $("div").fadeTo(3000, 0.3);
  <style type="text/css"> 
    div {
      background: #FC5E5E;
      font-family: arial;
      padding: 10px;
  <button id="fadeTo">fadeTo (3 Seconds)</button>
  <br /><br />
  <div>This element represent fade in/out effect.</div>

Run it...   »