This should work:

$("td.closeTab").click( function() {
       if (confirm("Are you sure you want to delete this tab?")) {
          var parentElt = $(this).parents("td.topTab:first");
          parentElt.remove();
          $(parentElt).next().remove();
          $(parentElt).prev().remove();
       }   // if
  } );

On 4/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Hi,

I have this HTML

<table><tr>
...
                <td><img src="images/spacer.gif" alt="" width="5"></td>
                <td class="topTab tabSelected" style="padding-left: 5px;
padding-
right: 5px;">
                        <table><tbody><tr>
                                <td class="tabText" id="tab12">nooo</td>
                        <td class="closeTab"><img src="images/close.gif"
alt="Close"
border="0"></td></tr></tbody></table>
                </td>
                <td><img src="images/spacer.gif" alt="" width="5"></td>
...
</tr></table>

when the user clicks the "close" button, I want to delete not only the
parent cell of the close button (the cell with class="topTab") but
also the two adjacent cells -- the ones containing the "spacer.gif"
image.  So far I have

                $("td.closeTab").click( function() {
                        if (confirm("Are you sure you want to delete
this tab?")) {
                                var parentElt = $
(this).parents("td.topTab:first");
                                parentElt.remove();
                        }   // if
                } );

What should I add to remove the other two cells?

Thanks, - Dave


Reply via email to