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 - finding element</title> </head> <body> <h2>Using "getElementById" method to find the element with in the document with a specific id.</h2> <p id="id1">This element has id = "id1".</p> <button onclick="findElement()">Access element</button> <script> function findElement() { const element = document.getElementById("id1"); element.innerHTML = "Element found!" } </script> </body> </html>
RunĀ