How come jQuery can't remove this element?

Posted by George Edison on Stack Overflow See other posts from Stack Overflow or by George Edison
Published on 2010-03-13T00:37:32Z Indexed on 2010/03/13 0:47 UTC
Read the original article Hit count: 323

Filed under:
|
|
|

I have a table like this:

<table id='inventory_table'>
  <tr id='no_items_avail'>
    <td>
      There are no items in the database.
    </td>
   </tr>
</table>

And I want to get rid of it with jQuery like this:

$('#inventory_table tbody tr#no_items_avail').remove();

However it doesn't seem to be working at all. What am I doing wrong?

Edit: Also, the row above was originally inserted into the DOM with another jQuery call:

$('#inventory_table tbody').append("<tr id='no_items_avail'.......

If that helps. And, running:

alert($('#no_items_avail').text());

yields "There are no items in the database." as expected.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about remove