JavaScript > If I set "var x = document.getElementById('inputText').value" and I update "x", why doesn't the value update?
<p>In the following example, why doesn't the "value" of the input "test" update to "second"?</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
    getText = function() {      
        var test = document.getElementById('test').value;
        test = "second";
       //note: if you insert "alert(test)" it returns "second"

    }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;label for="test"&gt;Test &lt;/label&gt;&lt;input type="text" id="test" value="first" onclick="getText()"&gt;&lt;/input&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
