jQuery fadeOut() Method
jQuery fadeOut() method perform fades out effect on the selected elements from visible to hidden.
Syntax
This syntax represent to the fadeOut method
$(selector).fadeOut( duration, easing, callback );
Parameter | Type | Description |
---|---|---|
duration | Number String |
Optional. Accept string or number that determining how long fading effect will run. default value is 400 Accepted values:
|
easing | String | Optional. Specifies the which easing function to use for the transition. default value is "swing" Accepted values:
|
callback | Function | Optional. A function to call once the fadeOut is complete. |
Example
Here, in this example show fadeIn and fadeOut effect on selected elements when click on button.
<!DOCTYPE html>
<html>
<head>
<title>jQuery fadeIn() and fadeOut() methods</title>
<script src="jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("#fadein").click(function(){
$("div").fadeIn(3000);
});
$("#fadeout").click(function(){
$("div").fadeOut(3000);
});
});
</script>
<style type="text/css">
div {
background: #FC5E5E;
font-family: arial;
padding: 10px;
}
</style>
</head>
<body>
<button id="fadein">Fade In (3 Seconds)</button>
<button id="fadeout">Fade Out (3 Seconds)</button>
<br /><br />
<div>This element represent fade in and fade out effect.</div>
</body>
</html>