prev

UK [prɪv] US [prɪv]

[MEDICAL] Prevention

jquery prev() method syntax

Function:prev() obtains the immediately preceding sibling element of each element in the matching element set. Filtering through the selector is optional.

Syntax:.prev(selector)

Parameters:

Parameter Description
selector String value, containing the selector expression used to match elements.

Description:If given a jQuery object that represents a collection of DOM elements, the .prev() method allows us to search for these elements in the DOM tree. The previous sibling element and constructs a new jQuery object with the matching element. This method accepts an optional selector expression of the same type as the argument we passed into the $() function. If this selector is applied, elements will be filtered by testing whether they match the selector.

jquery prev() method example

    
Hello

Hello Again

And Again

Run instance »

Click the "Run instance" button to view the online instance