jQuery selector with variable, not updating when variable changes
<p>'I am trying to do something like the below that will run a function when clicking the "hit" class only when the parent "box" id is correct.</p>

<pre><code>var selected = 1;    

$('#box-' + selected + ' .hit').click(function(){

    selected = randomFromTo(1,5);

});
</code></pre>

<p>The <code>selected</code> variable changes depending on other actions on the page but I can't get the function to work after any change - it stays fixed to the initially selected "box" id.  I can imagine why this might be, as jQuery has taken a snapshot of that string and nothing is telling it update it but I can't figure out how to get around this.</p>

<p><strong>Edit:</strong> added the selected variable's instantiation and where it gets set.  I've left out the UI changes that would make this more understandable to a user.</p>
