title: JS scope: accessing variable
body: <p>I know this question has been asked many times, but in different forms. I want to access the <code>selected</code> variable elsewhere within the scope of the topmost function (<code>alert</code> is currently returning undefined). I know I need to use a <code>return</code> in some way or another. Thank you in advance.</p>
  
  <pre><code>$('#people_search_mobile').change(function() {
  
    var selected;
  
    $('li a', $('#suggestions')).bind('click.autocomplete',function(){ 
      selected = ($(this).text());
    });
  
    alert(selected);
  
  }
  </code></pre>