screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head></head> <body> <h2>Javascript dynamically add text to div</h2> <div id="myDiv"></div> <button id="addTextButton">Add Text</button> <script> window.onload = function () { var div = document.getElementById("myDiv"); var addButton = document.getElementById("addTextButton"); addButton.onclick = function () { div.textContent = "This is the dynamically added text."; }; }; </script> </body> </html>