ConorReidd ConorReidd - 1 year ago 60
Javascript Question

Removing <tr> from table without :contains()


This may sound easier than it is, I need to use either Javascript or jQuery to remove a

from a table, I don't know what row this
will be, nor do i know which
I will be removing and the only way I can find out which
to remove is from the text inside the child's

I cannot use the :contains() selector from jQuery as I'm using ajax to get the elements and it just seems broken.


just gives me a DOMexception error.

Is there a way I can loop through all the
's in a table and check the text contents of them?

Answer Source

This will check the text of each one:

$('tr').each(function() {
  var $tds = $(this).find('td');
  $tds.each(function() {
    if ($(this).text() === "some text") {