Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Debugging Example</title> </head> <body> <div id="content">Hello, World!</div> <button id="change-text">Change Text</button> <p id="log"></p> <script> document.getElementById('change-text').addEventListener('click', function() { const content = document.getElementById('content'); const log = document.getElementById('log'); log.textContent = 'Current text: ' + content.textContent; content.textContent = 'Hello, Developer!'; log.textContent += ' | Updated text: ' + content.textContent; }); </script> </body> </html>