I've had a similar issue previously where I wanted to check if the background color is white and I've followed that solution which worked so I tried to do the same to check if 3 divs with different id's have the same background color but it only works with one of them, as soon as I add the other two ids it stops working
var counter=0;                   
 $(".circles").click(function() {
    counter++;
    if (counter % 2 === 0 && $(this).css("background-color") == whiteColor) {
        $(this).css("background-color", "black");
        $(".p1").css("font-weight", "bold");
        $(".p2").css("font-weight", "normal");
        var blackColor = $(this).css({
            backgroundColor: 'black'
        }).css('backgroundColor');
    } else if (counter % 2 === 1 && $(this).css("background-color") == whiteColor) {
        $(this).css("background-color", "red");
        $(".p2").css("font-weight", "bold");
        $(".p1").css("font-weight", "normal");
        var redColor = $(this).css({
            backgroundColor: 'red'
        }).css('backgroundColor');
    }
if ($("#one").css("background-color") == blackColor && $("#two").css("background-color") == blackColor && $("#three").css("background-color") == blackColor) {
$(".circles").hide();
};
})
HTML
    <div id="line1">
        <div class="circles" id="one">
        </div>
        <div class="circles" id="two">
        </div>
        <div class="circles" id="three">
        </div>
    </div>
    <div id="line2">
        <div class="circles" id="four">
        </div>
        <div class="circles" id="five">
        </div>
        <div class="circles" id="six">
        </div>
    </div>
    <div id="line3">
        <div class="circles" id="seven">
        </div>
        <div class="circles" id="eight">
        </div>
        <div class="circles" id="nine">
        </div>
    </div>
any idea how to fix this without redoing the whole code and use toggleclasses which would be the other alternative.
 
    