Welcome to FindNerd
Today we are going to discuss fadeToggle() method in jQuery.
Firstly let know what use of fadeToggle() Method ?
In fadeToggle() Method if the elements are faded out, fadeToggle() will fade them in and if the elements are faded in, fadeToggle() will fade them out.
syntex of fadeToggle() Method
$(selector).fadeToggle(speed,callback);
There are tow optional parametr in slideToggle() method
1-speed:-It can take values: "slow", "fast", or milliseconds.
2-callback:- This parameter is a function to be executed after the fading completes.
You can take reference of bellow example:
<!DOCTYPE html>
<html>
<head>
<!-- here call the jquery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").fadeToggle(2000);// here call fadeToggle() and pass callback parameter
});
});
</script>
</head>
<body>
<!-- define a button for clicking -->
<button>Click for Fade</button><br><br>
<!-- here write text and css -->
<div style="width:80px;height:40px;background-color:green; color:#fff; padding: 10px;">Working Fine</div>
</body>
</html>
0 Comment(s)