Reputation: 7345
$(".test").css('cursor','pointer');
<div class="test>0</div>
<div class="test>1,000</div>
How do I apply this to the elements that are not 0?
Upvotes: 3
Views: 2257
Reputation: 87073
$(".test").filter(function() {
return this.innerHTML != '0';
}).css('cursor','pointer');
<div class="test">0</div> <!-- missing closing quote-->
<div class="test">1,000</div> <!-- missing closing quote-->
Upvotes: 3
Reputation: 11431
You can use some thing like this:
if($(".test").text() != '0')
{
//Your code here
}
By using .text() it will get the text from the selector (as you may have imagined)
Upvotes: 0
Reputation: 4558
$('.test').each(function(){
if($(this).text() != '0')
$(this).css('cursor', 'pointer');
});
But the easiest would be to add a different class
Upvotes: 0
Reputation: 79830
If i assume correctly, you want cursor:pointer
to be applied to div with contents that are not 0. Try using filter like below,
$('.test').filter(function () {
return $(this).text() != '0';
}).css('cursor', 'pointer');
Upvotes: 1