Is there a way I can display the result and then have it fade away after about 10 seconds or something using JQuery?
Here is the code.
function stop(){
$.ajax({
type: "GET",
url: "http://update.php",
data: "do=getSTOP",
cache: false,
async: false,
success: function(result) {
$("#rate").html(result);
},
error: function(result) {
alert("some error occured, please try again later");
}
});
return false;
}
$(document).ready(function() {
$('.rating li a, .srating li a').click(stop);
});
The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector). fadeOut(speed,callback);
jQuery Effect fadeOut() Method The fadeOut() method gradually changes the opacity, for selected elements, from visible to hidden (fading effect).
The fadeIn method displays the element by fading it to opaque. The fadeOut method hides the element by fading it to transparent. Note – jQuery does the fading by changing the opacity of the element.
Main difference between FadeIn, FadeOut vs hide, Show is When you use FadeIn and fadeout Its remove line Slowly Like Opacity will 100 to 0 in a few mili-second but On other hand hide, Show will remove the line immediately Without wasting any mili-second.
You can use .delay()
for this, like this:
$("#rate").html(result).delay(10000).fadeOut();
This does a .delay()
for 10 seconds then performs a .fadeOut()
animation, no reason to make it any more complicated I think :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With