0

I want to delete all the rows of a table where the text of the first row matches a specific text. Take into account the text has to be an exact match. So if I look for those rows that contain the text "34" it should delete only those with the text "34" but not those with text "3434" for example. I was using "contains" before but it was deleting all rows containing "34" somwhere within the text, not only the exact matches.

I tried this but it isn't working since it doesn't delete anything.

$("#induction-table td").filter(function() {
   return $(this).text() == '"'+exp+'"';
}).closest("tr").remove();

So the text I want to match is in the variable exp. Also is there a way to check for the text only on one specific td of the tr and not on all? That would be pretty useful too.

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Atirag
  • 1,660
  • 7
  • 32
  • 60
  • 1
    do you really want to match a text wrapped in double-quotes? "some text"? – Roko C. Buljan Feb 14 '16 at 12:07
  • @RokoC.Buljan Thank you, that was it. – Atirag Feb 14 '16 at 12:18
  • @RokoC.Buljan Just one more thing. Do you know how can I look for the text only in one specific td? For example only on the first or second td. – Atirag Feb 14 '16 at 12:33
  • 1
    `$("#induction-table td:first-child")` or ``$("#induction-table td:nth-child(2)")`` – Mosh Feu Feb 14 '16 at 12:47
  • if your are still having problems check here for a method using each i answered a few days back -- http://stackoverflow.com/questions/35297863/jqgrid-automatically-hide-a-row-with-a-false-in-a-cell/35298393#35298393 – Tasos Feb 14 '16 at 12:49

0 Answers0