.andSelf() ** DEPRECATED **
.andSelf() method is used to add the previous set of elements on the jQuery stack to the current set of elements.
- When we chain our traversal or filtering methods together, many of the jQuery methods used operate on an existing jQuery instance and produce a new
jQueryobject that match a different set of elements. jQuery maintains the previous set of elements, as well as the new set of elements as an internal stack. We can visualize this stack where the newest set of elements is 'pushed' onto the stack. As we continue through our jQuery chain, each new traversal or filtering method will create a new set of elements that gets 'pushed' onto the stack. The
.andSelf()method allows us to add the previous set of elements from the stack to the current set of elements.
This method was deprecated in jQuery 1.8 and removed in jQuery 3.0 and is now used as an alias for the
.addBack() method added in jQuery 1.8 which should be used instead.
|Add the previous set of elements on the jQuery stack to the current set of elements.|
jQuery object either containing the elements matched or empty.