What is the difference between these codes?
Posted
by dhaliwaljee
on Stack Overflow
See other posts from Stack Overflow
or by dhaliwaljee
Published on 2010-06-01T12:14:08Z
Indexed on
2010/06/01
12:43 UTC
Read the original article
Hit count: 224
JavaScript
|difference
<input type='text' id='txt' name='txtName' size='20' value='testing'/>
<script type="text/javascript" language='javascript'>
var val = document.getElementsByName('txtName');
alert(val[0].value);
alert(window.txtName.value);
</script>
In above code we are using
alert(val[0].value);
alert(window.txtName.value);
these two ways for getting value from object. What is the difference between both ways and which way is best.
© Stack Overflow or respective owner