Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
$(".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?
$(".test").filter(function() { return this.innerHTML != '0'; }).css('cursor','pointer');
DEMO
<div class="test">0</div> <!-- missing closing quote--> <div class="test">1,000</div> <!-- missing closing quote-->
Add a comment
If i assume correctly, you want cursor:pointer to be applied to div with contents that are not 0. Try using filter like below,
cursor:pointer
$('.test').filter(function () { return $(this).text() != '0'; }).css('cursor', 'pointer');
$('.test').each(function(){ if($(this).text() != '0') $(this).css('cursor', 'pointer'); });
But the easiest would be to add a different class
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)
Required, but never shown
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.
Explore related questions
See similar questions with these tags.