jQuery closest class selector

后端 未结 6 595
野的像风
野的像风 2021-01-01 10:19
Click me
Information
6条回答
  •  暖寄归人
    2021-01-01 11:13

    Try .next() instead of .closest() that traverses through the ancestors of the DOM element.

    Working Demo

    Also you should use $(this) rather than $('.Level2') else it'll select ALL the .Level2 rather than the clicked one.

    You can also go for something like this - $(this).closest('.wrap').find('.Level3').fadeToggle();.

提交回复
热议问题