How to hide all the right siblings using jQuery?

$(this).parent().next().css('display','none');

The above only hides the sibling right next to the current one.

If there are several, it will fail.

+3
source share
1 answer

You need to use nextAll()

$(this).parent().nextAll().css('display','none');

or even better:

$(this).parent().nextAll().hide()
+9
source

Source: https://habr.com/ru/post/1715501/


All Articles