title: Finding the ID of the clicked element?
body: <p>Okay, I am not sure if this has been asked, exactly how I did, but sorry if yes.</p>
  
  <p>Basically, I have 10 items in a list.</p>
  
  <p>By running this query:</p>
  
  <pre><code>public function get10items()
  {
      $this-&gt;query = $this-&gt;pdo-&gt;prepare("SELECT * FROM items LIMIT 10");
      $this-&gt;query-&gt;execute();
  
      while ($row = $this-&gt;query-&gt;fetch(PDO::FETCH_ASSOC))
      {
          echo '&lt;li id="'.$row['id'].'"&gt;'.$row['name'].'&lt;/li&gt;&lt;br /&gt;';
      }
  }
  </code></pre>
  
  <p>This will list 10 items from the database into '&lt;ul&gt;'.
  This also will set an id to each item, with it's own number, like in the database.</p>
  
  <p>Now, with jquery, I want the jquery to find the ID number of the clicked item.</p>
  
  <p>For example our list:</p>
  
  <pre><code>Hello! [id55]
  Hai! [id66]
  </code></pre>
  
  <p><strong>I clicked on item 'Hello!'.
  How can I find out the ID of it upon click using jquery and then use it for future use?
  For example, sending ajax query, with that id, etc?</strong></p>
  
  <pre><code>&lt;ul class="list"&gt;
  &lt;?php echo $class-&gt;get10items(); ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>So basically I can use this:</p>
  
  <pre><code>$(".list").on("click", "li", function() {
      $.post("ajax.php", { get : this.id }, function() {
        blablabla
      });
  });
  </code></pre>
  
  <p>Is that correct?</p>