Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script> <style> #divId { height: 100px; width: 200px; border: 1px solid red; } </style> </head> <body> <div id='divId'> <span>Welcome to W3Docs</span> </div> <button id='buttonId'>Remove via innerHTML</button> <script> buttonId.onclick = () => { const myNode = document.getElementById("divId"); myNode.innerHTML = ''; } </script> </body> </html>