Delete a header row after all the other rows have been deleted
<p>I have a table that looks something like this:</p>

<pre><code>&lt;table&gt;
&lt;tr id="header"&gt;
    &lt;th&gt;Title&lt;/th&gt;
    &lt;th&gt;Title&lt;/th&gt;
&lt;/tr&gt;
&lt;tr id="1" class="record"&gt;
    &lt;td&gt;&lt;a class="delbutton"&gt;X&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Some Data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id="2" class="record"&gt;
    &lt;td&gt;&lt;a class="delbutton"&gt;X&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Some Data&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>And I have a jQuery script:</p>

<pre><code>$(function() {
    $(".delbutton").click(function(){

        //Save the link in a variable called element
        var element = $(this);

        //Find the id of the link that was clicked
        var del_id = element.attr("id");

        //Built a url to send
        var info = 'del_id=' + del_id;
        if(confirm("Are you sure you want to delete this entry?  This cannot be undone.")) {
            $.ajax({
                type: "GET",
                    url: "delete_entry.php",
                    data: info,
                    success: function(){
            }
        });

        $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");
    }
    return false;
    });
});
</code></pre>

<p>What I'm trying to do is to delete the header row (id="header"), or better yet, the remaining table  after the last data row has been deleted.</p>

<p>Any guidance would be great</p>

<p>Update:
After following Tom's recommendation I tried to count the rows.
I tried with:</p>

<pre><code>$('.record').size()
</code></pre>

<p>but that always reports the initial number of rows - it never accurately reports the row count after I delete a row.  Is it possible to keep track of just the remaining rows somehow?</p>

<p><strong>Resolution</strong>
This worked:</p>

<pre><code>$(function() {
    $(".delbutton").click(function(){

        //Save the link in a variable called element
        var element = $(this);

        //Find the id of the link that was clicked
        var del_id = element.attr("id");

        //Built a url to send
        var info = 'del_id=' + del_id;
        if(confirm("Are you sure you want to delete this entry?  This cannot be undone.")) {
            $.ajax({
                type: "GET",
                    url: "delete_entry.php",
                    data: info,
                    success: function(){
            }
        });

        $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");
                    //Remove - don't just hide                        
                    $(this).parents(".record").remove();

                    //If there are no more deleteable rows, delete the header
        if($('.record').length == 0) {
            $('#existTitle').animate({ backgroundColor: "#fbc7c7" }, "fast").animate({ opacity: "hide" }, "slow");
        }
    }
    return false;
    });
});
</code></pre>
