Sunday, 15 June 2014

jquery - Remove all divs where child element contains text greater than certain value -



jquery - Remove all divs where child element contains text greater than certain value -

i'm looking way remove divs on page class "property_container" contain kid elements text less value (preferably using jquery). realize text within < p > kid element need converted numeric-only value in order run comparing method.

for html, please see: http://jsfiddle.net/tqls4/

right now, step in direction, i've tried:

$(".property_container") .find(".property:contains('200000')") .parent() .remove();

i know contains method not need numeric if/then logic... basically, think need looks junky pseudo-code:

$(".property_container") .find((".price")asnumber < 200000) .parent("property") .remove();

or, in natural language: if p.price (a child) of div.property_container has numeric value (converted text value contained within < p > tag) less 200,000 hide/remove entire div.property_container.

use .filter

$(".property_container .price").filter(function() { homecoming parseint($(this).text().replace(/\d/g, ''), 10) < 200000; }).closest(".property_container").remove();

i noticed in fiddle text not number, contains dollar sign , comma separator, utilize replace() remove them before parsing it.

updated fiddle

jquery html css

No comments:

Post a Comment