I'm trying to get the value of input but the console is showing up "undefine". What am I doing wrong?
<input name = "foo" value = "value">
<script>
var text = document.getElementsByName("foo").value;
console.log(text);
</script>
I'm trying to get the value of input but the console is showing up "undefine". What am I doing wrong?
<input name = "foo" value = "value">
<script>
var text = document.getElementsByName("foo").value;
console.log(text);
</script>