Use the jquery prev of method to find the previous element of the sibling
- 2020-03-30 03:31:58
- OfStack
Retrieve each paragraph and find the previous sibling element of the class named "selected" :
$("p").prev(".selected")
The.prev() method allows us to search the DOM tree for the previous sibling of these elements and construct a new jQuery object with matching elements.
The.prev() method finds the previous element of the sibling of the current element