How can I check to make sure the siblings don’t contain the class I am looking for before I start traveling up the DOM with closest()? I could do it with the closest() and siblings() functions but I am wondering if there is a jquery function that already exists that would take care of this.
How can I check to make sure the siblings don’t contain the class I
Share
closest()looks up the DOM,siblings()looks to either side; I don’t believe there’s any jQuery method that does both. You’ll have to start withsiblings()(possibly with.andSelf()) and then test thelengthto see if you need to checkclosest()instead.