jQuery has the following fade methods:
- fadeIn()
- fadeOut()
- fadeToggle()
- fadeTo()
fadeIn() Method - fade in a hidden element.
Syntax:
/*
speed - fast | slow | milliseconds
callback - optional
*/
$(selector).fadeIn(speed,callback);
#example.html
<!DOCTYPE html>
<html>
<head>
<title>jQuery Fading Methods</title>
<style>
div{
background: green;
padding: 10px;
margin: 5px;
display: none;
}
</style>
</head>
<body>
<button>Click to fade in</button><br><br>
<div id="div1">div 1</div>
<div id="div2">div 2</div>
<div id="div3">div 3</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("button").click(function() {
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
});
</script>
</body>
</html>