How to write jQuery Effect fadeOut() Method?
<!DOCTYPE html>
<html>
<head>
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js”>
</script>
<script>
$(document).ready(function(){
$(“.btn1”).click(function(){
$(“p”).fadeOut()
});
$(“.btn2”).click(function(){
$(“p”).fadeIn();
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button>Fade out</button>
<button>Fade in</button>
</body>
</html>
Definition and Usage
The fadeOut() method gradually changes the opacity, for selected elements, from visible to hidden (fading effect).
Note: Hidden elements will not be displayed at all (no longer affects the layout of the page).
Tip: This method is often used together with the fadeIn() method.
Syntax
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the fading effectPossible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is “swing”Possible values:
Tip: More easing functions are available in external plugins |
callback | Optional. A function to be executed after the fadeOut() method is completed |