Prev Demo
JavaScript
>
Finding HTML Element From Html Page
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Finding elements using ID</h1> <script> function TestFunction() { alert(document.getElementById("lblText").innerHTML); } </script> <label id="lblText">0</label> <input type="button" id="btnTest" onclick="TestFunction()" value="Click me" /> <p><strong>Note:</strong> The id="lblText" is conncted with HTML and JavaScript. <br> Click the button to get the alert.</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output