jQuery prev and next methods
The prev method can be used to access the top neighbor of a given element, while next can be used to access the bottom neighbor (note that elements are considered neighbors only within the same parent).
Let's take the following paragraphs as an example:
<p>text</p>
<p>text</p>
<p id="test">text</p>
<p>text</p>
<p>text</p>
Now we find the element #test and put the text '!' to its neighbor above:
$('#test').prev().html('!');
Now let's perform a similar operation with the neighbor below:
$('#test').next().html('!');
Find the first element that immediately precedes the element with class test.
Find the first element that immediately follows the element with class test.