To find the html controls by their id attribute, we can follow this approach.
<script> function TestFunction() { alert(document.getElementById("lblText").innerHTML); } </script> <label id="lblText">0</label> <input type="button" id="btnTest" onclick="TestFunction()" value="Click me" />
In the above function, getElementById finds a label with id “lblText” and shows its inner HTML content as an alert.
OUTPUT
Views: 4463 | Post Order: 57