HTML/CSS/Java Display text for 10 sec, then hide text?

  • Thread starter Thread starter Adam M
  • Start date Start date
A

Adam M

Guest
How can I make it so that I have text appear on my page for the first 10 seconds, then delete itself after?

A basic code would be nice, i can edit HTML&CSS (Java is a little more work for me).

Thanks!
 
Javascript:
<script type="text/javascript">
function hide() {
document.
getElementById('hideit').
innerHTML= "";
}

setTimeout(hide(),10000);
</script>

Remove the line breaks in the function hide() so it is all one line. (had to do it so then it wouldn't cut off)

HTML:

<p id="hideit">Put text here to hide</p>

How it works:
It will work how you do it, I'd suggest you put the script after the <p> to make sure there are no errors.

The script works by setting a timeout, after 10,000 milliseconds, it will then disappear. If you need more help, e-mail me.
 
Back
Top