title: Passing HTML attribute to jQuery function from onclick event
body: <p>I have a problem in passing one of html element to jQuery. I know that with <code>attr()</code> we can access to attributes. Nevertheless I feel I do something wrong.</p>
  
  <p>This is my simple jQuery function:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function test(value) {
          alert(value);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><br>
  I have a dynamic listbox which has been created by foreach loop:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;select  multiple="multiple" name="factors1" id="main_factors" style="width: 200px; height: 200px;"&gt;
  
  &lt;?php foreach ($array as $option): ?&gt;
      &lt;option onclick="test(&lt;script&gt;this.attr('title').value&lt;/script&gt;);"
              id="&lt;?php echo $option[0]; ?&gt;"
              title="&lt;?php echo $option[2]; ?&gt;" 
              value="&lt;?php echo $option[0]; ?&gt;"&gt;
          &lt;?php echo $option[1]; ?&gt;
      &lt;/option&gt;
  &lt;?php endforeach ?&gt;
  
  &lt;/select&gt;
  </code></pre>
  
  <p>I want when somebody click on items in list box its item show in my messagebox for example. However this code did not work for me. </p>
  
  <pre><code>onclick="test(&lt;script&gt;this.attr('title').value&lt;/script&gt;);"
  </code></pre>
  
  <p>How can I send title attribute value to my function from onclick attribute?</p>
  
  <p>Thanks in advance.</p>