Menu ▼

Previous Next

id :

The attribute id represents the id of the control, we will use id to identify the control, even in JavaScript we will find the control by its id.

Syntax :

<input type="text" id="textboxid" />


Example :

<html>

<head>

    <title>HTML Tutorial</title>

    <script language="javascript">

        function ShowInput() {

            var input = document.getElementById("txtinput");

            if (input != null)

                alert(input.value);

        }

    </script>

</head>

<body>

    Enter input :

    <input type="text" id="txtinput" />

    <input type="button" id="btnShow" onclick="ShowInput();" value="Show entered input" />

</body>

</html>


Output :
HTML Tutorial Enter input :
Previous Next




Search dotnetlearners.com