Alex Ezell wrote:
> <div id="searchResult_16" class="searchResult">
> <div class="resultTitle">Turkey</div>
> <div class="resultPrice">6.95</div>
> </div>
> [ ... ]
> Then the user uses a slider to send the maximum price as 7.00. How
> would I, using jQuery obviously, find the elements whose resultPrice
> is higher than 7.00 and remove it from display, not totally remove it
> from the DOM, just hide it?
As a previous poster noted, one simple way would be to do something like
this:
$(".searchResult").show().filter(function(index) {
return ($(".resultPrice", this).text() > filterPrice);
}).hide();
One caveat, though, is that you are tying this functionality very
closely to the exact HTML structures you are using. It's essentially a
screen-scraping technique, and if you decided to change the HTML in some
way so that the .resultPrice is not inside the .searchResult, you would
also need to change this Javascript.
One alternate approach clears this up at the expense of duplicate data
being sent in the page: include in your output a Javascript array of the
data and the related id's, and then iterate through that array, hiding
and showing the related elements based on a function that runs against
the actual data.
I'm not suggesting that the latter is better. It involves more code and
more bandwidth, but this should be balanced against the fragility of
screen-scraping in the context of your particular application.
Good luck,
-- Scott
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/