title: Why can't I get the value of this text input field?
body: <p>I have a div, which contains a text input field:</p>
  
  <pre><code>&lt;div id="age" class="fullScreen"&gt;
    &lt;input type="text" id="age" class="textInput" placeholder="Please enter age..." /&gt;
    &lt;button type="button" onclick="submitAge()"&gt;Submit&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>submitAge() looks like this:</p>
  
  <pre><code>function submitAge() {
    var ageVal = document.getElementById("age").text;
    alert(ageVal);
  }
  </code></pre>
  
  <p>But in Google Chrome and Webkit Nightly I see an alert with the text "undefined" (I can't test in any other browsers because the page contains web-sockets).</p>
  
  <p>The chrome developer tools show this:</p>
  
  <p><img src="https://i.stack.imgur.com/A0oeM.png" alt="ageVal: undefined"></p>
  
  <p>I assume that the problem is that the input is not in a form, but I don't want it to be in a form because I will be submitting the data via websockets.</p>
  
  <p>Do I have to put it in a form or is there a better solution?</p>
  
  <p>Thanks.</p>