How about adding the is(':visible') check to this conditional so the "visible" var will accurately reflect the state of the element's visibility. Maybe even pull that out into a separate function, eg: this.isVisible() like this.parentVisible().