Reputation: 569
I have a problem with the script jquery:
I have a paragraph of an e-mail. When I click on it. I want the text changed to "Copied to clipboard" with fade effect. After 3 seconds returned the original text with fade efect
I have a problem back to the original text (link)
Upvotes: 0
Views: 26
Reputation: 96
try this in click event
$('.icon-email').click(function () {
var email =$(this).text();
$(this).fadeOut(500, function() {
$(this).text('Copied to clipboard').fadeIn(500,function()
{
$(this).fadeOut(3000, function() {
$(this).text(email).fadeIn(500);
});
});
});
});
Upvotes: 1
Reputation: 2807
you can use the animate function for the above requirement:
$('.icon-email').click(function () {
$(this).animate({opacity:0},function(){
$(this).text("new text")
.animate({opacity:1},3000); //3000 is the speed that you wanted to fade in and fade out
})
});
Upvotes: 0