This code in Meteor need to change the background color to yellow on click and back to white on another click, I tried few ways after reading others solutions but could not get it to work.
How can I change the color to yellow if it is white and to white if it is yellow. I need to code other things in the conditional statement as well later.
The HTML is:
<p>{{car.carID}} <strong class="toggleBackground">{{car.plate}}</strong></P>
Thanks
'click .toggleBackground': (e) => {
//$(e.target).addClass('yellow'); // tried with css file for no avail
console.log($(e.target).css("background-color"));
//tried === rgba(255, 255, 0) instead of yellow for no avail
if($(e.target).css('background-color') === 'yellow'){ //<<< never true
console.log('already yellow'); //<<< never called
$(e.target).css('background-color', 'white');
} else {
console.log('will make yellow');
$(e.target).css('background-color', 'yellow');
}
}
.white{
background-color: #FFFFFF
}
.red{
background-color: yellow
}