jquery dynamically genearate element id in a loop
<p>This is a loop in a function intending to create elements <code>&lt;li&gt;</code> and give each <code>&lt;li&gt;</code> an unique id. But it's not working. I suspect it's a simple syntax error with the use of quote in .attr(). But I can't get a straight answer from Google.  </p>

<pre><code>for (i=0;i&lt;array.length;i++)
{
//create HTML element of tag li
$('#suggest').append("&lt;li&gt;&lt;/li&gt;");
$("li").attr("id",'li'+i);
$('#li'+i).html(array[i]);
}
</code></pre>
