title: Check if an HTML element is expecting a source attribute
body: <p>Following on from my previous question. I made a helper function(see below), to insert elements into the DOM. Part of the function uses 'instanceof' to determine if 'this' element is an instance of an HTMLMediaElement and determines the source attribute by way of the argument 'elemSrc'. </p>
  
  <p><strong>My question:</strong> Is there a way to check if an element is 'expecting' a source attribute to be defined? The reason I ask is, I could then use this function for all elements that 'expect' to have a source attribute defined. I know I could use instanceof &amp; reel off every element that employs the source attribute, but I would prefer a slicker way if possible.</p>
  
  <pre><code>function insertElem(numberOfElems, elemTag, elemId, elemClass, parentSelector, elemSrc){
      /*
      * numberOfElements:-    Pass in a whole integer.
      * elemTag:-             Pass in the element tag type (inside "" or '').              
      * elemId:-              Pass in a name for the element id (inside "" or ''),
                              an integer is appended to the id name by the for loop.
      * elemClass:-           Pass in a name for element class (inside "" or '').
      * parentSelector:-      Pass in the identifier of the parent element (inside "" or '')
                              * querySelector prefixes:    # = id
                                                           . = class
                                                           none = tag 
      *elemSrc:-              Pass in the source media url (inside "" or ''). 
      */      
        if (numberOfElems &gt; 1) {
          for (i = 0; i &lt; numberOfElems; i++) {
            var elem = this[elemId + i];
            elem = document.createElement(elemTag);
            elem.id = elemId + '_' + i;
               if (elemClass) {
                  elem.className = elemClass;
               }
            parentEl = document.querySelector(parentSelector);
            parentEl.appendChild(elem);
              if(elem instanceof HTMLMediaElement) {
                  elem.src = elemSrc;
              }
          }
        } else {
          var elem = this[elemId];
          elem = document.createElement(elemTag);
          elem.id = elemId;
              if (elemClass) {
                  elem.className = elemClass;
              }
          parentEl = document.querySelector(parentSelector);
          parentEl.appendChild(elem);
             if(elem instanceof HTMLMediaElement) {
                  elem.src = elemSrc;
            }
        }
      }
  </code></pre>