To get the next element you can use the .next()
method.
<ul>
<li>Mark</li>
<li class="anna">Anna</li>
<li>Paul</li>
</ul>
If you are standing on the "Anna" element and you want to get the next element, "Paul", the .next()
method will allow you to do that.
// "Paul" now has green text
$(".anna").next().css("color", "green");
The method takes an optional selector
argument, which can be used if the next element must be a certain kind of element.
// Next element is a "li", "Paul" now has green text
$(".anna").next("li").css("color", "green");
If the next element is not of the type selector
then an empty set is returned, and the modifications will not do anything.
// Next element is not a ".mark", nothing will be done in this case
$(".anna").next(".mark").css("color", "green");