Reliable way to get the "ancestor" of an object with a specific classname, using jQuery
<p>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.</p>

<p>This select element is in a td tag, in a tr tag.  The tr tag has a classname of "FilterDetailsRow".</p>

<p>Now, I've tested, and if I use this syntax:</p>

<pre><code>var filterRow = $(this).parent().parent();
</code></pre>

<p>it gets me what I want.  However, is there a better way to tell jQuery, "starting with "this" can you please go up my tree of parents until you find one with a classname of "FilterDetailsRow"?</p>

<p>Here's what I came up with, but I want to make sure I"m not reinventing the wheel.</p>

<pre><code>function GetFilterDetailsRowOfObject(o) {
    if (o) {
        if (o.parent()[0].className.indexOf("FilterDetailsRow") != -1)
            return o;
        else
            return GetFilterDetailsRowOfObject(o.parent());
    } else {
        return null;
    }
}
</code></pre>

<p>Thanks for any advice.</p>
