how to check for duplicates list text before adding it to the list using jquery?
<p>Let say I have the following ul List:</p>

<pre><code>                  &lt;ul id='testList'&gt;

                            &lt;li&gt;dfsdfdsfs&lt;/li&gt;
                            &lt;li&gt;dfsdfdsfs&lt;/li&gt;
                            &lt;li&gt;dfsdfdsfs&lt;/li&gt;
                            &lt;li&gt;dfsdfdsfs&lt;/li&gt;
                            &lt;li&gt;dfsdfdsfs&lt;/li&gt;
                  &lt;/ul&gt;
</code></pre>

<p>Next, I need to check this list for duplicates before adding an item to the list:</p>

<pre><code>                 $("#testList li").each(function()
                 {
                     if(output == $(this).text())
                     { 
                            alert("duplicate entry");
                     }else
                     {
                         $("#testList").append("&lt;li&gt;"+output+"&lt;/li&gt;");
                     }

                 });
</code></pre>

<p>Problem, the else statement is not being added when the list is empty...</p>
