I have a div that I'd like to fade-out after say 30 seconds. Is there a simple Jquery plugin that will do that for me? Thanks

1 answer

danwellman 5600
1
point
This was chosen as the best answer

There may be a plugin for it, but to be honest, a plugin isn't really needed

Just have an id on the div in your mark-up, e.g:

<div id="fadeMeOut"></div>

Then in your script just do:

<script>
    $(function() {
        $("#fadeMeOut").delay(30000).fadeOut()
    });
</script>

This will cause the div to fade out after 30 seconds (30000 milliseconds)...

See this fiddle to watch it in action (note: the fiddle fades the div after 1 second to avoid making you wait for ages to see it happen...)

Answered over 7 years ago by danwellman
  • What a great answers, thanks. If I wanted to use fadeOut and a couple of other scripts on the same page, how would I separate them between the <script></script> tag? Thanks again. sbl2000 over 7 years ago
  • which other scripts do you need to use? You can just use multiple <script> blocks if necessary danwellman over 7 years ago
  • that's what I've been doing........I just there was a more graceful way. Thanks again. sbl2000 over 7 years ago