Any way to apply onclick events to a large list of li dynamically?
<p>Ok, I have an unordered list like so:</p>

<pre><code>&lt;ul id=list&gt;
    &lt;li&gt; Item 1 &lt;/li&gt;
    &lt;li&gt; Item 2 &lt;/li&gt;
    &lt;li&gt; Item 3 &lt;/li&gt;
    &lt;li&gt; Item 4 &lt;/li&gt;
    &lt;li&gt; Item 5 &lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>Is there any simple way of creating onclick events for each of the individual li's?</p>

<p>Here's my objective... I have CSS setup like so:</p>

<pre><code>#list li {...some styles here...}
#list li:active {...change background color and font color on click...}
</code></pre>

<p>So again, any simple way of doing this? I know I can achieve it by simply adding an onclick event to each of the individual li's, but any smart way of doing this?</p>

<p>(For clarification - I'm actually going to be using an 'ontouchstart' event for mobile webkit)</p>
