jQuery example for val() of input box
<p>The <a href="http://api.jquery.com/val/" rel="nofollow">example</a> for finding the value of an input box in jQuery is below.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;style&gt;

  p { color:blue; margin:8px; }
  &lt;/style&gt;
  &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;input type="text" value="some text"/&gt;
  &lt;p&gt;&lt;/p&gt;
&lt;script&gt;
    $("input").keyup(function () {
      var value = $(this).val();
      $("p").text(value);
    }).keyup();
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>I have 2 questions.</p>

<ol>
<li>Why is the script inside the body? (I tried putting it between the head tags and it <em>does not</em> work).</li>
<li>Why are there two different keyup() methods, one directly after $("input") and the other after the function?</li>
</ol>
