Seven circles but only one is changing colour, why?

前端 未结 8 1263
梦谈多话
梦谈多话 2021-01-26 09:29

I am new to javascript and I have an assignment to create seven circles which should change colour on a mouse click. The first circle is changing colour but the other six just r

8条回答
  •  面向向阳花
    2021-01-26 09:42

    id attributes are for referencing single Items, while Class attributes are for referencing group of items..

    so changing ID to Class would look like this.. -

     
        
        
        
        
        
        
        
        
    
        
    

    and then you get the group of items by their class name using this..

    var circle = document.getElementsByClassName("circle1");
    

提交回复
热议问题