vendredi 28 juillet 2017

jquery if statement only half working

I can't for the life of me figure out why this won't work

$("#color").click(function () {

        if ($("a").css("color", "#ffffff")) {
       $("a").css("color","#ff0000");
     } else  {
         $("a").css("color", "#ffffff");
     };

      });

The first time you click, it changes the color. But it won't change it back if you click again.

everything I've looked at seems to tell me my syntax is fine but it's just not working.

Aucun commentaire:

Enregistrer un commentaire