Show my link & ldquo; Delete & rdquo; only if I have more than one image in my image list


Im deleting banner images using jQuery and Ajax.

But if I have just one image I dont want to delete it.

I have a list of images, and for each image I have this link:

echo '<a class="delete j_bannerdelete" id="'.$rslt_banner['id'].'" href="#">Delete</a> ';

And I was thinking something about tihs, just show "Delete" link if my row count was more than 1.

if($read_ban->rowCOunt() >1{
     echo '<a class="delete j_bannerdelete" id="'.$rslt_banner['id'].'" href="#">Delete</a> ';

But like this, for example If I have 2 images, I delete one, and as Im deleting with ajax, my page dont refresh, so I have my last image with my "Delete" link and so I can delete it.

Do you know a a simple way to solve this?

My delete code:

    var banner_id = null;
        $('.bannerli li[id="'+ banner_id +'"]').css('background','#f5f5f5');
        banner_id = null;
        if (!banner_id) return;
        $.post(url,{action:'ban',id: banner_id},function(){
                $('.bannerli li[id="'+ banner_id +'"]').fadeOut("slow");
        banner_id = $(this).attr('id');
        $('.bannerli li[id="'+ banner_id +'"]').css('background','red');
        $('.delete_dialog p').text('Are you sure you want to remove this banner?');
        return false;

I created a simplified solution here: It should give you an idea of how to do it.

Basically you want to count how many items you have:

if($('.bannerli').length <= 1) { /* Hide delete */ }

And you want to do this check everytime an item is deleted. If items can also be added, you also need to check if you have more than one item and in that case show all the delete-buttons again.