Remove whole table when inside a class is matched?

Remove whole table when inside a class is matched?

At first the code:

  1. <table>
  2. <tbody>
  3. <tr>
  4. <td >
  5. <div class="foobar">....</div>
  6. ...</td>
  7. </tr>
  8. </tbody>
  9. </table>

When a table contains a certain class the whole table should be removed.

The following does NOT work:

$("table .foobar").remove();

How else?