I'm having trouble locating a specific post about this issue.
Essentially, I want to hide the Compare
text if the data-product-id
is less than someValue
After doing some research, I came up with this code snippet. There are no errors, but the code doesn't seem to be working as expected. I suspect there is something wrong with my code.
Could someone please explain what's incorrect in my code and provide guidance on how to correct it?
$("a[data-product-id]").filter(function() {
return parseInt($(this).attr("data-product-id")) < 99335;
$('.show').addClass('hide');
});
.hide {
display: none !important
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" class="button" data-product-id="99336" rel="nofollow"><p class="show">Compare</p></a>
<a href="#" class="button" data-product-id="99335" rel="nofollow"><p class="show">Compare</p></a>
<a href="#" class="button" data-product-id="99334" rel="nofollow"><p class="show">Compare</p></a>
<a href="#" class="button" data-product-id="99333" rel="nofollow"><p class="show">Compare</p></a>