Jump to content

Any way to fade out box after X seconds?


Orionsbelter

Recommended Posts

Is there a way to fade out this bit off code after 15 seconds?

 

<table width='95%' border='1' align='center' cellpadding='5' cellspacing='0'>
              <tr>
                <td bordercolor='#317082' bgcolor='#FFFFB7' class='adminResponse' align='center'>$response</td>
              </tr>
            </table><br>

 

Is it just a box which has some text in but after 15 seconds i want it to fade away any way off doing this?

Link to comment
https://forums.phpfreaks.com/topic/183657-any-way-to-fade-out-box-after-x-seconds/
Share on other sites

Yes.  What you want to do is change the opacity of the element using css or microsoft IE specific filters.  The code is quite complicated however, and you can find pre-canned effects in most of the various javascript libraries.  There's no particular magic to it -- you simply need to have a fadeout() function that increases the opacity of a css style until it reaches 100.

 

There's an excellent article with several examples and the nuts and bolts of this here ->  http://www.itnewb.com/v/Cross-Browser-CSS-Opacity-and-the-JavaScript-Fade-Fading-Effect

Download this:

http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js

 

Then use this code:

<script type="text/javascript" src="jquery-1.3.2.js"></script>
<div id="fadeout">Hello World</div>

<script>
    window.setTimeout(function() {
        $('#fadeout').hide(2000);
    }, 15000);
</script>

Download this:

http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js

 

Then use this code:

<script type="text/javascript" src="jquery-1.3.2.js"></script>
<div id="fadeout">Hello World</div>

<script>
    window.setTimeout(function() {
        $('#fadeout').hide(2000);
    }, 15000);
</script>

 

That wont work unless you place it in a jquery object.

 

<script>
$(document).ready(function(){
    window.setTimeout(function() {
        $('#fadeout').hide(2000);
    }, 15000);
});
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.