Find parent and first child of it's parent

前端 未结 4 1355
無奈伤痛
無奈伤痛 2021-02-19 23:44

I am trying to find the parent of an element and it\'s parent first child, the code is like this:

        
  • &l
4条回答
  •  长发绾君心
    2021-02-20 00:15

    $('.selected').parent().siblings(':first-child').children().addClass('selected');
    

    FIDDLE DEMO

提交回复
热议问题