HTML
    | Change particular
  • color onclick and other
  • in the same
      to default color

前端 未结 6 464
青春惊慌失措
青春惊慌失措 2021-01-18 22:06

I want to have 5 lists such than when any of them is clicked, it turns to green and turn the other lists to black if any of them is green.

Here\'s m

6条回答
  •  孤城傲影
    2021-01-18 22:54

    One solution is this:

    $("ul > li").on("click", function(){
        $("ul li").css("color", "black");
        $(this).css("color", "green");   
    });
    li{
        list-style:none;
        cursor:pointer;
    }
    
    

提交回复
热议问题