Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find text and remove it jquery [duplicate]

Possible Duplicate:
Find text string using jQuery?

How do you find a text string and hide it with jquery.

<div class="report-box">
  <div class="title">test</div>
  <table>
    <tbody>
      <tr align="center" class="CellLabel">
        <td colspan="2">Day at a Glance</td>
      </tr>
      <tr class="CellLabel">
        <td>New Clients</td>
        <td>00000</td>
      </tr>
      <tr class="CellLabel">
      <  td>Money Received</td>
        <td>$ 0000,000.0000</td>
      </tr>
      <tr class="CellLabel">
        <td>Overdue Invoices</td>
        <td>0000000</td>
      </tr>
      <tr class="CellLabel">
        <td>Services</td>
        <td>000000</td>
      </tr>
      <tr align="right" class="CellLabel">
        <td colspan="2"></td>
      </tr>
    </tbody>
  </table>
</div>

How would I remove

<tr class="CellLabel">
  <td>Money Received</td>
  <td>$ 0000,000.0000</td>
</tr>

from the code using a jquery.

like image 811
Kenp Avatar asked Feb 25 '26 18:02

Kenp


1 Answers

First off, your html is a bit messy, lacks a few tags. But here you go. ;)

1:

Preview - http://jsfiddle.net/Xpc63/1/

$('.CellLabel').removeByContent('Money');​

See preview for full JS code.

2:

Preview - http://jsfiddle.net/ahzPs/1/

$('.CellLabel').contains('Money').remove();​

See preview for full JS code.

3:

Preview - http://jsfiddle.net/mWtzw/

$('.CellLabel').filter(function() {
    return $(this).html().indexOf('Money') != -1;
}).remove();​
like image 74
Jānis Avatar answered Feb 27 '26 08:02

Jānis