John K John K - 5 months ago 12
jQuery Question

Looking for jQuery find(..) method that includes the current node

The jQuery find(..) traversal method doesn't include the current node - it starts with the children of the current node. What is the best way to call a find operation that includes the current node in its matching algorithm? Looking through the docs nothing immediately jumps out at me.

Answer

For jQuery 1.8 and up, andSelf is deprecated and you can use addBack instead. It takes a selector so you don't need to filter the result:

object.find('selector').addBack('selector')
Comments