Have you ever been deeply nested in some html and need to call out to a parent nested way up many more levels? Well, typically in jQuery you would have had to do something like this $(“#selector).parent().parent()…etc. Well, I thought I would share an interesting little function I found today, the parents() function, I have an example below.
$("#selector").parents("#selectorToFind");
As you can see, all you have to do is feed it the selector, “selectorToFind” and it will traverse up the tree and find the element that I am looking for.