title: Change link class on click
body: <p>I'm somewhat new to JS, specially AJAX.
  I would like to change the class of a certain link based on which link I click in, for reference see below:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;ul id="top" class="example" style="visibility: visible;"&gt;
  
  &lt;li&gt;&lt;a style="custom style here" href="#" title="Blonde"&gt;Blonde&lt;/a&gt;&lt;/li&gt;
  
  &lt;li&gt;&lt;a style="custom style here" href="#" title="Blonde"&gt;Blonde&lt;/a&gt;&lt;/li&gt;
  
  &lt;li&gt;&lt;a style="custom style here" href="#" title="Brown"&gt;Brown&lt;/a&gt;&lt;/li&gt;
  
  &lt;li&gt;&lt;a style="custom style here" href="#" title="Black"&gt;Black&lt;/a&gt;&lt;/li&gt;
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>(Note that the hashtags are just a placeholder for Ajax calls)</p>
  
  <p>What I am currently doing using jQuery:</p>
  
  <pre><code>jQuery('#top').bind('click',function test(event) { //jQuery because WordPress
      var button = jQuery( event.target.title );
      return button;
  });
  </code></pre>
  
  <p>The thing is, no matter how i try to "obtain" the value of <code>button</code> it never seems to work, I tried outputting to an alert, nothing. Also tried writing it to the javascript console, also nothing.</p>
  
  <p>But this is just a small hiccup in the rest of the code. 
  My ultimate goal is to bind all those <code>a</code> links to a <code>click</code> event, and then when any link is clicked, it pulls the value that <code>title</code> has(brown, black, etc) from the link and will then add a class to that very same link (the one that ends up being clicked). </p>
  
  <p>For reasons that surpass me, the code that should in theory retrieve the <code>title</code> value is in a different function than the code which will add the CSS class based on the link clicked, so to sum this up, what would be the best way to go about passing that variable from one function to another ? </p>
  
  <p>I tried this <a href="https://stackoverflow.com/questions/4611190/passing-variables-in-jquery#4611215">Passing variables in jquery</a> and also this one <a href="https://stackoverflow.com/questions/14553092/jquery-passing-a-parameter-between-functions">Jquery passing a parameter between functions</a> but for some reason it doesn't seem to work, maybe because of my previous errors ?</p>
  
  <p>Thanks</p>