Set VAR on click and alert the value
<p>Why can't I get this to work??</p>

<p>I want to get the index() from the menu, and alert() the value when the hash changes, which it does. </p>

<p>The alert doesn't appear.</p>

<pre><code>    $('#menu li a').click(function() {
        var index = $(this).parent().index()+1;
    });



    $(window).bind('hashchange', function () { //detect hash change
        var hash = window.location.hash.slice(1); //hash to string (= "myanchor")
        alert(index);
    });
</code></pre>

<p>Can you tell me what I'm doing wrong???</p>
