Articles → JavaScript → Document.Getelementbyid In Javascript

Document.Getelementbyid In Javascript








Assigning Id To Control In HTML




<input type="text" id="txtName">



What Is Document.Getelementbyid





Example




<html>
	<head>
		<script language="javascript" type="text/javascript">
    		function ClickMe()
    		{
    			alert(document.getElementById("txtName").value);
    		}
	    </script>
	</head>
	<body>
		<form method="post" action="GetElementByIDPage.html">
			<input type="text" id="txtName">
		    <input type="button" value="click" onclick="javascript:ClickMe();">
	    </form>
	</body>
</html>




Picture showing the output of document.getElementByID in JavaScript

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, December 31, 2010

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250