Jquery/Javascript parent problem

[SIZE=2]


$('input[id^="system"]').change(function() {
    var id = $(this).attr('id');
    var parents = $('#' + id)
                        .parents()
                        .map(function () { 
                            return this.id; 
                        });
    var fieldset = parent[2]; // 3rd parent element is a fieldset
});

At the moment the the third parent of the input is a fieldset, which is fine, but I would like the script to explicitly get the fieldset element, rather than just land on it as the third parent. any ideas?
[/SIZE]

$(this).closest(“fieldset”)

parents() also accepts a filtering expression, but closest() should be more efficient because you only want one element.

That’s great, saves me a few lines of code too.