document.write():-
इसका उपयोग simple text और testing purpose के लिए किया जाता है।
ध्यान दें: पेज लोड होने के बाद (जैसे किसी बटन के क्लिक पर) document.write() का उपयोग करेंगे तो पूरा पेज हटकर सिर्फ नया कंटेंट दिखेगा।
<button onclick="document.write('Page Over!')">Click me</button> <!-- This will erase the entire page -->
syntax:-
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<script>
document.write(5 + 6);
</script>
</body>
</html>
document.write():-
It is used for simple text and testing purposes.
Note: If you use document.write() after the page has loaded (e.g., on a button click), the entire page will be erased and only the new content will be shown.
<button onclick="document.write('Page Over!')">Click me</button> <!-- This will erase the entire page -->
syntax:-
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<script>
document.write(5 + 6);
</script>
</body>
</html>