Is there a way to locate the next link after an active class within a class and then apply the active class to that new link? I attempted to use the next()
function, but it doesn't seem to be functioning as expected.
$("#next").on("click", function() {
$(".test a.active").next(".test a").addClass("active");
});
.active { color: red; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="test"><a href="" class="testx active">a</a></div>
<div class="test"><a href="" class="testx">b</a></div>
<div class="test"><a href="" class="testx">c</a></div>
<div class="test"><a href="" class="testx">d</a></div>
<div class="test"><a href="" class="testx">e</a></div>
<button id="next">click</button>