<p class="current" style="display: block; ">MD</p>
<input type="text" class="hidden" value="MD" style="display: none; ">
<p class="small hidden" style="display: none; ">MD, MBBS etc.</p>
<a class="save-field-data btn hidden" data-id="medical_degree" href="#" style="display: none; ">Save</a>
The above explains my Html dom elements.
Say i am in a handler attached to the class "save-field-data"
How can i set the text of class current?
.prevAll()should help in this situation:I added the
.eq(0)to select the first match in-case there are several.currentelements that are siblings of the clicked.save-field-dataelement.Docs for
.prevAll(): http://api.jquery.com/prevallNote: the difference between
.prevAll()and.siblings()is that.prevAll()only searches the sibling elements that precede the current selection and.siblings()will select all siblings no matter if they come before or after the current selection.