Select Matching Ancestors .parents()

.parents([selector])

e.g. $("b").parents("div")

.parents(selector) will find the matching ancestors.

Example 1: $("b").parents() will find all ancestors of <b>.
<div>
  <p>
    <span>
      <b>a</b>
    </span>
  </p>
</div>
Example 2: $("b").parents("div") will find <div> ancestors of <b>.
<div>
  <p>
    <span>
      <b>a</b>
    </span>
  </p>
</div>
jQuery traversing tree .parents()