0

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>
frosty
  • 2,559
  • 8
  • 37
  • 73

0 Answers0