How to count li which does not have ul?

前端 未结 3 710
野趣味
野趣味 2021-02-15 00:39

Hi I want to count LI which does not have the UL , for the first level only, but when I count this it shows size 4 instead of 2, its count the inner LI also.

&l         


        
3条回答
  •  花落未央
    2021-02-15 01:06

    Not sure if I'm reading right, but ..

    $('ul.first-level > li:not(:first)').length
    

    Returns 2 for me (see demo)

提交回复
热议问题