jQuery prev Method

Last Updated Jul 21, 2015, 12:00:06 PM





jQuery prev Method

jQuery prev() method constructs a jQuery object which will get the immediate sibling element of the selected element in DOM tree. Siblings are the elements which same parent element.

Syntax

In the syntax, the selector is an optional parameter to pass and specify a selector expression to narrow down the previous sibling search.

Let us look at the following example to understand about the .prev() jQuery method

Example

The above example will move its current style to its immediate sibling who is called its jQuery prev element



Output

jquery prev() method
Try It Now

Other Advanced jQuery Traversing Methods you might want to learn

jQuery Basic Traversing

jQuery Traversal Filters

jQuery Traversing Methods

Sources and Credits

The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation

Last Updated Jul 21, 2015, 12:00:06 PM