Objectives and outcomes

In this tutorial we are going to learn about jquery fade effect. We can fade DOM elements visibility using jquery fadeIn(), fadeOut() and fadeTo() methods. Example for the same is shown below:

Syntax for method


You can learn about selector in our Jquery selector tutorial while the speed parameter defines the pace of the effect. It can have values like "slow", "fast" and milliseconds. callback parameter is a function which is executed after the fade method complete its execution.
Note: Both the parameters are optional in fadeIn() and fadeOut() method.
While the opacity and speed parameter in fadeTo() method is not optional.

Learn Jquery with codeshot !!

HTML code:

<meta charset="utf-8">
<title>Jquery fade effect</title>
<script src="jquery/jquery.min.js"></script>
<div id="example">
<p><b>Learn Jquery with codeshot !!</b></p><br/>
<button id="butn1">fadeOut</button><br/>
<button id="butn2">fadeIn</button><br/>
<button id="butn3">fadeTo</button>

CSS stylesheet