Online HTML Editor
Javascript Online Compiler
index.html
Change Theme
Compress code
Uncompress code
Download Code
Clear Code
Copy Code!
RunĀ
Click to run or ctrl+s
Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Javascript - innerHTML example</title> </head> <body> <h2>"innerHTML" property gets and sets inner content of the element.</h2> <p id="id1">This is <strong>Paragraph 1</strong>.</p> <div id="id2"> <div class="column"> <p>This is column 1.</p> </div> <div class="column"> <p>This is column 2.</p> </div> </div> <button onclick="textNode1()">Show node1 innerText</button> <button onclick="textNode2()">Show node2 innerText</button> <script> const node1 = document.getElementById("id1"); const node2 = document.getElementById("id2"); function textNode1() { alert(node1.innerHTML); } function textNode2() { alert(node2.innerHTML); } </script> </body> </html>
RunĀ