Get the immediately preceding sibling of each element in the set of matched elements.
// <label>Name</label><input class="current">
$('.current').prev().addClass('bold');
<label class="bold">Name</label>
<input class="current">
$('li').prev('.header').addClass('highlight');
// Adds 'highlight' to the previous sibling
// ONLY IF it matches '.header'.
| Parameter | Type | Description |
|---|---|---|
| selector | string | Optional. If specified, retrieves the previous sibling only if it matches this selector. |
Returns: A new SR object.