code: function ownerWindow ( $elem ) {
          var elem = $elem[0],
              ownerDocument = elem && ( elem.nodeType === 9 ? elem : elem.ownerDocument );
  
          return ownerDocument && ( ownerDocument.defaultView || ownerDocument.parentWindow ) || $.isWindow( elem ) && elem || undefined;
      }
docs: Does the actual work of $.fn.ownerWindow. Protected from external modification. See $.fn.ownerWindow for details.
  
  @param   {jQuery} $elem
  @returns {Window|undefined}