what is the difference b/w these codes javascript ?
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:23 UTC
Read the original article
Hit count: 157
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 b/w both ways and which way is best.
© Stack Overflow or respective owner