title: How to get the id of html list item using jquery?
body: <p>I wanna get the id of <code>&lt;li&gt;</code>  using jquery. I was able to get the text using <code>alert($(this).text())</code> but when I tried <code>alert($(this).id())</code> it says <code>undefined</code>.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css"&gt;
   ul {
    list-style-type: none;
   }
  &lt;/style&gt;
  &lt;script type="text/javascript" src="jquery1.6.4min.js"&gt;&lt;/script&gt;
   &lt;script type="text/javascript" &gt; 
    $(document).ready(function() {
     $('#list li').click(function() {
      alert($(this).id());
      alert($(this).text());
     });
    });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;ul id="list"&gt;
    &lt;li id="l1"&gt;Value 1&lt;/li&gt;
    &lt;li id="l2"&gt;Value 2&lt;/li&gt;
    &lt;li id="l3"&gt;Value 3&lt;/li&gt;
    &lt;li id="l4"&gt;Value 4&lt;/li&gt;
    &lt;li id="l5"&gt;Value 5&lt;/li&gt;
    &lt;li id="l6"&gt;Value 6&lt;/li&gt;
    &lt;li id="l7"&gt;Value 7&lt;/li&gt;
    &lt;li id="l8"&gt;Value 8&lt;/li&gt;
    &lt;li id="l9"&gt;Value 9&lt;/li&gt;
    &lt;li id="l10"&gt;Value 10&lt;/li&gt;
    &lt;li id="l11"&gt;Value 11&lt;/li&gt;
    &lt;li id="l12"&gt;Value 12&lt;/li&gt;
   &lt;/ul&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Plase help me with this. Thanks in advance.</p>