Select Previous Sibling .prev([selector])

.prev([selector])

selector is optional
e.g. $("span").prev()

.prev([selector]) will select prev adjacent sibling, if selector is provided then it should match selector.

Example 1: $("span").prev() will find previous adjacent sibling of each <span>.
<b>A</b>
<span>B</span>
<b>C</b>
<span>D</span>
<div>E</div>
Example 2: $("span").prev("div") will only find previous adjacent sibling of type <div> for each <span>.
<b>A</b>  //prev but NOT div 
<span>B</span>
<b>C</b>
<div>D</div>
<span>E</span>

jQuery traversing tree .prev([selector])