Find the deepest and the last li in any li blocks in a ul li list using jquery?

后端 未结 3 803
礼貌的吻别
礼貌的吻别 2021-01-15 14:07

I have a list in HTML. There are several nested ul and li.When I click on a li, I want to find a deepest item in that li tag that has no ul tag inside and the li is the last

3条回答
  •  清歌不尽
    2021-01-15 14:39

    Something like this should do the trick...

        $('.liclk').click(function() {
    
            var el = $(this).find("ul:last-child").find('li:last-child').css("background-color", "red");
        });
    

提交回复
热议问题