How to iterate through ul list using Javascript?

后端 未结 4 1276
闹比i
闹比i 2020-12-28 18:54

I have the following HTML page (page is simplified here as it is a sample of the real one):





        
4条回答
  •  旧时难觅i
    2020-12-28 19:33

    I know you can't use jQuery for this, but I thought I'd supply a solution for others that may be able to:

    $(function(){
        $("li a").click(function(){
            $(this).parent().siblings().each(function(){
                $(this).find("a").css({'color':'blue','background-color':'white'});    
            });
            $(this).css({'color':'white','background-color':'black'});    
            return false;
        });
    });
    

提交回复
热议问题