Hi,
I am curious about this simple Javascript code : I am getting the result , but the question is how is it that 'document.getElementById('txt').value' works even when I have not given the
'id' attribute in the textbox?
<html>
<head>
<script type="text/javascript">
function fn()
{
alert(document.getElementById('txt').value);
}
</script>
</head>
<body>
<input type="text" name="txt">
<input type="button" name="bt" value="Click" onClick="fn();">
</body>
</html>
Javascript : simple
Moderator: General Moderators
Re: Javascript : simple
When using getElementById some browsers, like IE, will use the name attribute value, when id is not given...