1

I have the following:

 <div class="showcaseBeds">0 Bedroom</div>
 <div class="showcaseBaths">0.00 Total Bathroom</div>
 <div class="IDX-showcaseBeds">3 Bedrooms</div>
 <div class="IDX-showcaseBaths">3.00 Total Bathrooms</div>

I want to hide the div if the showcaseBeds inner html == 0 Bedroom aswell as hide the showcaseBaths if inner html == 0.00 Total Bathroom

I have found a few jquery solutions that hinged on the attributes but not the inner html.

 $('div.item:has()').remove();​
tyler
  • 1,273
  • 2
  • 16
  • 40
  • Not quite a duplicate, but http://stackoverflow.com/questions/4811962/how-to-css-select-element-based-on-inner-html indicates that it is not possible across all browsers, and gives a workaround involving jQuery. – Adrian Wragg Jul 26 '13 at 15:00
  • @AdrianWragg thanks for the link! Ill check it out. – tyler Jul 26 '13 at 15:05

2 Answers2

2

Use :contains() selector:

$("div.item:contains('"+ text + "')").remove();
YD1m
  • 5,845
  • 2
  • 19
  • 23
  • Thanks! so i would include this twice one for each text string im looking to remove – tyler Jul 26 '13 at 14:57
  • I tried your suggestion here http://jsfiddle.net/qDKrD/1/ with no luck. Where am I going wrong with syntax? – tyler Jul 26 '13 at 15:03
1

You should use (You used wrong class)

$("div.IDX-showcaseBeds:contains('0 Bedroom')").remove();
$("div.IDX-showcaseBaths:contains('0.00 Total Bathroom')").remove();

DEMO.

The Alpha
  • 143,660
  • 29
  • 287
  • 307