3
$(".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?

4 Answers 4

3
$(".test").filter(function() {
   return this.innerHTML != '0';
}).css('cursor','pointer');

DEMO

Correction to your HTML

<div class="test">0</div>  <!-- missing closing quote-->
<div class="test">1,000</div> <!-- missing closing quote-->
Sign up to request clarification or add additional context in comments.

Comments

1

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');

Comments

0
$('.test').each(function(){
    if($(this).text() != '0')
        $(this).css('cursor', 'pointer');
});

But the easiest would be to add a different class

Comments

0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.