fixed jQuery undefined error when target is hidden