Closed laburr27 closed 7 years ago
@laburr27 You're comparing the strings "blueA1" and "blueQ1" -- not the variables -- inside of your if statement. Try removing the quotation marks.
Trying this using IDs instead of the NAME attribute. Got the first IF ELSE to work but now working on the second...
$("#bA1").click(function(){ // $("#blueFb").css("background-color", "green"); if ("blueA1" == "blueQ1") { $("#blueFb").css("background-color", "green"); } else { $("#blueFb").css("background-color", "red"); } });
$("#bA2").click(function(){ // $("#blueFb").css("background-color", "green"); if ("blueA2" == "blueQ1") { $("#blueFb").css("background-color", "green"); } else { $("#blueFb").css("background-color", "red"); } });
That did it!
So confusing when you need to use the quotes (") and when you don't...
Thanks!
:+1:
Just know that if you surround it with quotes, you are not getting back the value stored in the variable. You are literally getting back the letters/words you have inside the quotes.
I tried:
I expected the background color to change to red.
The background color stayed the default (purple) instead.
My repo link is https://github.com/laburr27/trivial-pursuit
and my question is about lines 22 - 27 in script.js.