[Solved] jquery if background is red doesn’t recognize error, looks easy but stubborn
Why is this fiddle not working? Many reasons. 1) CSS property background is not background-color 2) background-color is not red but rgb(255, 0, 0) Working code: $(document).ready(function(){ $(“.box”).click(function(){ if ($(“.box”).css(“background-color”) == “rgb(255, 0, 0)”) { $(“.box”).html(“Success!”); } }); }); Working Jsfiddle link Side note: debugging with console.log() is much more convenient than alert() Side note … Read more