-1

Hello how to change the color of a circle in turn with the same button without the preceding circle does not change color

$(document).ready(function(){
  $("#btn1").click(function(){
    $("#circle1").css("color", "green");
  });
});

thanks you for your help

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
  • Please add the relevant HTML and CSS to your question. – Scott Marcus Jun 07 '18 at 13:54
  • Your syntax seems correct using JQuery as seen in this possible duplicate [**https://stackoverflow.com/questions/2001366/how-can-i-change-the-text-color-with-jquery**](https://stackoverflow.com/questions/2001366/how-can-i-change-the-text-color-with-jquery) - If you experience issues you would need to post the exact HTML you have and tell us about any errors/warning you see in the console, assuming there is any. – Nope Jun 07 '18 at 14:04

1 Answers1

-1

one way to do it would be to addClass and removeClass instead of changing the color property.

That way you could verify if this element has that class and do accordingly.

for example

 $(document).ready(function(){

    $("#btn1").click(function(){
     if($("#circle1").hassClass"orange")
       {
       $("#circle1").removeClass("orange").addClass("green");
       }
       else
       {
       $("#circle1").removeClass("green").addClass("orange");
       }


    });
 });
Budyn
  • 563
  • 7
  • 21