3

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.

3

4 Answers 4

4

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();​
Sign up to request clarification or add additional context in comments.

Comments

0

You could use the contains selector method:

$('td:contains("$ 0000,000.0000")').parent().hide();  //to hide

$('td:contains("$ 0000,000.0000")').parent().remove();  //to remove

Or, if you just want to remove or hide the td that contains the text:

$('td:contains("$ 0000,000.0000")').hide();  //to hide

$('td:contains("$ 0000,000.0000")').remove();  //to remove

Comments

0
$('.cellLabel').find('td:contains("money")').remove();

Comments

0
// just want to remove
$('.cellLabel').find('td:contains("Money Received")').parent.remove();

Or

 // if just want to hide
 $('.cellLabel').find('td:contains("Money Received")').parent.hide();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.