JavaScript can generate dynamic HTML content:
Date: Mon, Nov 18, 2024 12:46:21 GMT+0530 (India Standard Time)
<!DOCTYPE html> <html> <body> <script> document.getElementById(“demo”).innerHTML = “Date : “ + Date(); </script> </body> </html> |
In JavaScript, document.write() can be used to write directly to the HTML document.
<!DOCTYPE html> <html> <body> <p>Bla bla bla</p> <script> document.write(Date()); </script> <p>Bla bla bla</p> </body> </html> |
Avoid using document.write() after the document has loaded, as it will overwrite the entire document. |