Is there any difference in following 2 jquery code snippet?
<p>Is there any difference in following 2 jquery snippet? Both gives same output but does any one have any advantage over other or they are just one's choice to write like this to do the thing.</p>

<p>Snippet 1:</p>

<pre><code>div = $("#myDiv");
div.append("&lt;ul&gt;");
$.each(cobj, function(k,v) {
    div.append("&lt;li&gt;&lt;span class='"+v+"'&gt;"+k+"&lt;/span&gt;&lt;/li&gt;");
});
div.append("&lt;/ul&gt;");
</code></pre>

<p>Snippet 2:</p>

<pre><code>$("&lt;ul&gt;").attr("id", "myUL").appendTo("#myDiv"); 
$.each(cobj, function(k, v) {  
    var li = $("&lt;li&gt;");  
    $("&lt;span&gt;").text(k).attr("class",""+v}).appendTo(li);
    li.appendTo("#myUL");  
});  
</code></pre>
