jQuery addBack()
jQuery addBack()
is a useful function that adds the previous element or selector to the current set of matched elements in a chain, allowing you to include elements that were previously excluded or removed.
Syntax
The addBack()
function can be used in the following ways:
$(selector).addBack()
$(element).addBack()
Use
addBack()
is useful when you want to include an element or a selector that was previously removed or excluded in a chain of jQuery methods. It is also useful for chaining multiple jQuery methods together to perform more complex operations on matched elements.
Example
Here is an example of using addBack()
to include the previous selector in a chain: