Appending Jquery HTML?
<p>I am trying to append the text of a link inside a <code>&lt;li&gt;</code> to a <code>&lt;ul&gt;</code> The problem is getting it to scan through and find duplicates and not add a new <li>. </p>

<p>Here is the code:</p>

<pre><code>$('.popular-list li a').live("click",function() //this will apply to all anchor tags
        { 
                var stuff = $(this).text();
                var match = $('#favoritesdrinks li:contains(' + stuff + ')');


                if(match) {
                        alert("Already Added")
                } else {
                        $('#favoritesdrinks').append('&lt;li&gt;'+stuff+'&lt;/li&gt;');


                }


        }
);
</code></pre>

<p>UPDATE- THIS IS WORKING CODE:</p>

<pre><code> $('.popular-list li a').live("click",function() //this will apply to all anchor tags
        { 
                var $stuff = $(this).text();
          var hasDuplicate = false;

      $('#favoritesdrinks li').each( function(){
       if ($(this).text() === $stuff ){
          hasDuplicate = true;
          return false;
       }
    });

    if (hasDuplicate ) {
       alert("Already Added") } 
    else {         
       $('#favoritesdrinks').append('&lt;li&gt;'+$stuff+'&lt;/li&gt;'); 
    }
});
</code></pre>
