javascript - .next() jquery function skips next sibling -
i trying remove class element , add class next element. problem next element gets skipped. here javascript: var $active = this.$view.find('.active'); if ($active.index() !== this.$view.children().length - 1) { $active.next('.list-group-item').addclass('active'); $active.removeclass('active'); } here html: <div> <a class="list-group-item active">1</a> <a class="list-group-item active">2</a> <a class="list-group-item active">3</a> <a class="list-group-item active">4</a> </div> $('.list-group-item').on('click',function(){ debugger; var $active = $(this).parent().find('.active'); if ($active.index() !== $(this).parent().children().length - 1) { $active.next('.list-group-item').addclass('active'); $active.removeclass('active'); ...