"Append if doesn't exists" in jQuery
<p>I'm trying to write a helper function for jQuery that creates an element if it doesn't already exist. So far I have:</p>

<pre><code>function setup(element, parent){
  if($(parent).child(element).length == 0){
    $(parent).append('&lt;div class="'+element+'"&gt;&lt;/div&gt;');
  }
}
</code></pre>

<p>but I'm wondering if this isn't a solved problem. Is it?</p>

<p>(The reason I want this is so I can pull in JSON content and put it in the right place. If the right place exists, I'll just update the content. If it doesn't exist, I'll create it.)</p>
