Friday, 25 September 2015

jQuery fadeIn()

jQuery fadeIn()

jQuery fadeIn() method is used to fade in the element.
Syntax:
$(selector).fadein();
$(selector).fadeIn(speed,callback);  
$(selector).fadeIn(speed, easing, callback);  
speed: It is an optional parameter. It specifies the speed of the delay. Its possible vales are slow, fast and milliseconds.
easing: It specifies the easing function to be used for transition.
callback: It is also an optional parameter. It specifies the function to be called after completion of fadein() effect.
Let's take an example to demonstrate jQuery fadeIn() effect.
<!DOCTYPE html>  
<html>  
<head>  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>  
<script>  
$(document).ready(function(){
    $("button").click(function(){
        $("#div1").fadeIn();
        $("#div2").fadeIn("slow");
        $("#div3").fadeIn(3000);
    });
});
</script>  
</head>  
<body>  
<p>See the fadeIn() method example with different parameters.</p>  
<button>Click to fade in boxes</button><br><br>  
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><br>  
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div><br>  
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>  
</body>  
</html>   

Output:
See the fadeIn() method example with different parameters.

No comments:

Post a Comment