remove a div from returned function(data)
<p>I am running a jQuery <code>$.post</code>function that returns data from a php page.  In that page some divs with specific ids get created.  What I need to do is delete a div if it's already found on the current web page, but let the others go through.  Here's the code:</p>

<pre><code>var phpDivs = [];
$(data).filter("div").each(function(){ phpDivs.push(this.id); });
var pageDivs = [];
$("#items").find("div").each(function() { pageDivs.push(this.id); });

$.each(phpDivs, function(indexphp, phpDiv) {
    $.each(pageDivs, function(indexpage, pageDiv) {
        if (pageDiv == phpDiv) {
            alert("match");
            $(phpDiv, $(data)).delete(); //problem code
        }
    });
});

$(data).appendTo("#items").show("slide", {direction: "right"}, 500);
</code></pre>

<p>The commented line above appears to delete all divs, instead of just a specific div.  I've also tried:</p>

<pre><code>$('"#'+ phpDiv + '"', $(data)).delete();
</code></pre>

<p>with the same result.</p>

<hr>

<h3>Edit</h3>

<p>Came across something interesting.  If I replace the problem code with this:</p>

<pre><code>data = $(data).html("&lt;p&gt;blah&lt;/p&gt;");
</code></pre>

<p>Then it will actually change the data object.  I cannot use <code>$(data)</code>.  However, I still can't get this to work the way I want with no idea what the problem is.</p>
