-2

I have one paragraph in my html file. I need to write a Java Script function to show this paragraph, 5 seconds after opening the html file.

1 Answers1

0

I solved it here is solution :

var myVar=setInterval(function(){myTimer()},5000);

function myTimer()
{
var t="This is a Paragraph.";
document.getElementById("p").innerHTML=t;
}
    <!DOCTYPE html>
    <html>
        <head>
            
          
    <script src="7b.js"></script>
    
        </head>
        
        <body>
      
    <p id="p"></p>
        </body>
    </html>
  • Only that the text in the paragraph is updated on every 5 seconds. Use `setTimeout` instead. – Teemu Nov 30 '17 at 05:42