Home >>jQuery Tutorial >jQuery fadeTo() method
jQuery fadeTo() method in jQuery is an inbuilt method which is used to gradually changes the opacity (fading to a given opacity), of the selected elements.
Syntax:$(selector).fadeTo(speed,opacity,easing,callback)
Parameter | Description |
---|---|
speed | It is an optional parameter and is used to Specify the speed of the fading effect. Its default value is 400 milliseconds
Possible values:
|
easing | It is an optional parameter and is Specify the speed of the element in points of the animation. Its Default value is "swing"
Possible values:
|
callback | It is an optional parameter. After the fadeTo() method is completed a function to be executed |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("h1").fadeTo(1000, 0.4);
});
});
</script>
</head>
<body>
<button>click me te see effect</button>
<h1>PHPTPOINT</h1>
</body>
</html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<h4>
click on me
</h4>
<h4>
click on me
</h4>
<script>
$("h4:first").click(function() {
$(this).fadeTo("slow", 0.33);
});
</script>
</body>
</html>