Skip to content Skip to sidebar Skip to footer

Reliable Way To Get The "ancestor" Of An Object With A Specific Classname, Using Jquery

I've got a javascript function that gets called on change event of a select form element. So, the 'this' variable in js refers to the select element. This select element is in a t

Solution 1:

You can use closest to find the first matching ancestor:

var filterRow = $(this).closest('.FilterDetailsRow');

Solution 2:

In jQuery 1.4 you can use parentsUntil. For you it would be something like

$(this).parentsUntil('.FilterDetailsRow');

Post a Comment for "Reliable Way To Get The "ancestor" Of An Object With A Specific Classname, Using Jquery"