jQuery closest class selector

后端 未结 6 610
野的像风
野的像风 2021-01-01 10:19
Click me
Information
6条回答
  •  一向
    一向 (楼主)
    2021-01-01 11:02

    Yes! closest starts the DOM search from the selector you pass to it, and goes upwards the DOM hierarchy, searching through the parents/ancestors. Use siblings or next instead. Like this:

    $('.Level2').click(function(){
        $(this).siblings('.Level3').fadeToggle();
    });
    

提交回复
热议问题