title: Undefined JS alert
body: <p>I've got an <strong>a-tag</strong> which reads as this: (and there are number of a-tags being dynamically populated as this stays inside a PHP loop.)</p>
  
  <pre><code>echo "&lt;a onclick='trygettheid();' class='mainList' id='main' href='index.php?idd=".$reK['catid']."'&gt;&lt;div class='AS1'&gt;".$reK['catdescriptor']."&lt;/div&gt;&lt;/a&gt;";
  </code></pre>
  
  <p>and the JS function looks like below.</p>
  
  <pre><code>function trygettheid()
  {
      var myvariable = $(this).attr('id');
      alert(myvariable);
  }
  </code></pre>
  
  <p>The issue is when a click is triggered, the alert says <strong>'undefined'</strong> instead of the desired output of <strong>'main'</strong></p>
  
  <p>Am I missing anything here?</p>