Adding li element only if it not already there?
<p>I am constructing an <code>&lt;li&gt;</code> element like this:</p>

<pre><code>var element = $("&lt;li&gt;&lt;/li&gt;") 
    .html(mHTML)  
    .attr('id', "elemid");
</code></pre>

<p>I am trying to add this element to a <code>&lt;ul&gt;</code> element only if it doesn't already exist. Any ideas on how to do this? Am I supposed to use <code>contains()</code> to see if the <code>ul</code> element contain the html and then decide? For instance,</p>

<pre><code>&lt;ul id="elemul"&gt;
  &lt;li id="elemli1"&gt;Element 1&lt;/li&gt;
  &lt;li id="elemli2"&gt;Element 2&lt;/li&gt;
  &lt;li id="elemli3"&gt;Element 3&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>If I try adding Element 1, it should not add it. What should I do if its a longer string (not really long but about 150 characters). </p>

<p><strong>Note: I cannot rely on IDs to determine the uniqueness.</strong> i.e. I might end up forming something like: <code>&lt;li id="elemli3"&gt;Element 1&lt;/li&gt;</code></p>

<p>Do I go about using hashmaps?</p>
