I have a question, which I thought I would solve it by myself, but somehow, I could not. I am using jQuery to check whether the class single-page contains a plus or a minus. If there is a plus, I want the icon1 to be green. If there is a minus, I want it to be red.
<div class="blocking single-page">
<div class="thumbs-for-you">
<span class="icon1"></span>
<span class="icon2"></span>
</div>
<span class="rate">-100</span>
</div>
What I tried is (this is just one of the dozen things I tried):
$('.single-page:contains("-")').removeClass('.icon2');
$('.single-page:contains("-")').removeClass('icon2');
I did not got it to work. I also tried using children and siblings, but with no effect. I am guessing that there is no way to use removeClass and contains together. Am I wrong or not?
Can somone help me out solving this issue please?
PS: a little description --> if I remove the classes icon1 and 2, the images will be automatically gone.
Try
You are applying wrong syntax.
Try to do following
.removeClass('icon2'); instead
.removeClass('.icon2');
Read API removeClass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With