why hidden field value won't be updated
<p>Look at this code :</p>

<pre><code>        function ToggleMenu() {
            var v = $("#MenuVisibility").val() ;
            if (v == "1") {
                $('#MenuVisibility').val("0");

            }
            else {
                $('#MenuVisibility').val("1");
            }
            v = $("#MenuVisibility").val();
            alert(v);

        }
    &lt;/script&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;input type="hidden" value="1" id="MenuVisibility" /&gt;
    &lt;form id="form1" runat="server"&gt;

    &lt;div id="Menu"&gt;
        &lt;a class="MainMenu" href="#" onclick="OpenCloseMenu()"&gt;Fun&lt;/a&gt;
        &lt;div id="ExtendedMenu"&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href="#"&gt;Item 1&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="#"&gt;Item 2&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="#"&gt;Item 3&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="#"&gt;Item 4&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="#"&gt;Item 5&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;asp:Button ID="Button1" runat='server' Text="Toggle Menu" OnClientClick="ToggleMenu()" /&gt;

    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>When i click for first time , hidden field value sets to 0 , but when I click for second time, it value won't changed to 1 . why ? </p>
