I have a listbox which (sometimes) uses OptionGroups as well, meaning that if I select the parent of a certain OPTION in my listbox, as follows:
var optionGroup = $(this.options(index)).parent();
it can either be an OptionGroup (if they’re used), or the Select element itself.
Is there an easy way of determining which kind of object I’m dealing with here?
You could use
.parent('optgroup'). This will filter out anything that isn’t an optiongroup. Then you’d have to check if you get a result of course.