Reputation: 1009
I want to lookup prices inside
tags (plain text). For instance if p.price < 10000 then hide its parent. Im thinking something along the lines of
$(".price").val() < 10000.parent().hide();
Obviously that is syntactically incorrect....can anyone tell me if this is possible and how i'd go about cleaning up my code? Thanks
Upvotes: 0
Views: 42
Reputation: 148150
You can use each() or filter().
$(".price").each(function(){
if($(this).val() < 10000)
$(this).parent().hide();
});
OR
$(".price").filter(function(){
return $(this).val() < 10000;
}).hide();
Edit based on comments
$(this).val().replace('£','').replace(/,/g,'')
Your code would be
$(".price").each(function(){
if($(this).val().replace('£','').replace(/,/g,'') < 10000)
$(this).parent().hide();
});
Upvotes: 2