How to get the data value from a list item, using jquery, when it is clicked
<p>I have some Html like:</p>

<pre><code>&lt;div id="adiv"&gt;
    &lt;ul&gt;
            &lt;li data-id="3"&gt;Cat&lt;/li&gt;
            &lt;li data-id="4"&gt;Dog&lt;/li&gt;
        &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>What I wanted was to alert the data-id value when the user clicks the list item.</p>

<p>In jquery I tried:</p>

<pre><code>$('li').click(function () {
        alert(this.attr('data-id'));
    });
</code></pre>

<p>Throws an exception though. Can anybody tell me what I'm doing wrong and how to fix?</p>

<p>Exception is: Microsoft JScript runtime error: Object doesn't support property or method 'text'</p>
