<div id="sometext">
This text will Fade In and Out.
</div>
Code language: HTML, XML (xml)
Now we can use jQuery to fadein and out this text. Just copy following text. $("#something").fadeOut("slow");
...
$("#something").fadeOut(2000);
...
$("#something").fadeOut("slow", function() {
alert("Animation done");
});
Code language: JavaScript (javascript)
I have shown 3 tricks to fade out a div/text. In first code, a div with id something is slowly fade out using fadeOut() function. Note that we have passed an argument “slow”. You can also pass a number that represents milliseconds in this function. fadeOut() function also takes second argument which is a call back function that gets called when animation is over. Here in the example I have passed a simple handler function that alerts a text after the animation. Similarly you can use fadeIn() function to achieve fade in functionality. $("#something").fadeIn("slow");
...
$("#something").fadeIn(2000);
...
$("#something").fadeIn("slow", function() {
alert("Animation done");
});
Code language: JavaScript (javascript)
The below code will fadeIn all the text in paragraph <p> tag. $("p").fadeIn("slow",function(){
alert("Animation Done.");
});
Code language: JavaScript (javascript)
$("p").fadeTo("slow", 0.5);
...
$("p").fadeTo("slow", 0.5, function(){
alert("Animation Done.");
});
Code language: JavaScript (javascript)
Hope you will like this trick. jQuery is simply amazing. Update: Adding Online Demo for FadeIn FadeOut using jQuery. Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…
View Comments
Any demo will be great to see how it works :)
Nice tutorial , is there any demo of this example.
Agreed. Can you please set up a demo? :)
@Shabu, @Neel, @Derrick : Online demo added. Thanks for the comments.
Nice tutorial, thanks for sharing with us...
sweet tutorial! ty!
Is it possitble to do it the other way around. if you press the button the text fade in. Instead of pressing the button and fade out
@Tunge2, did you ever find out, I want to do this, so if you did, could you please share how with me. Thanks
Is it possible to dynamically change text using XML or Access?
Nice. Thank you,