jQuery fadeTo() method is used to fading to a given opacity. Opacity means the contents of the layer will be invisible because they are completely transparent.
Syntax:$(selector).fadeTo(speed, opacity);
$(selector).fadeTo(speed, opacity, callback);
$(selector).fadeTo(speed, opacity, easing, callback);
speed: It specifies the speed of the delay. Its possible vales are slow, fast and
milliseconds.
opacity:It specifies the opacity. The opacity value ranges between 0 and 1.
easing: It specifies the easing function to be used for transition.
callback: It is also an optional parameter. It specifies the function to be called after
completion of fadeToggle() effect.
Example of Code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".example-jquery-fadeto-button").click(function(){
$("#example-jquery-fadeto-paragraph").fadeTo(1000, 0.4);
});
});
</script>
<button class="example-jquery-fadeto-button">It change the opacity of the p element</button>
<p id="example-jquery-fadeto-paragraph"> Paragraph.</p>
Output
Paragraph.
