title: JQuery: create array from element's name and create list
body: <p>I would like to getElement's names => make an array => create a menu as list => add some clickbehaviour CSS. When exercising I already found a way to get all elements but could not reach their names.
  The elements I am aiming for look like this <code>&lt;a class="jqsubmenu" name="ELEMENTSNAME"&gt;&lt;/a&gt;</code>. </p>
  
  <p>The HTML-Code to be produced needs to be like <code>&lt;div id="#submenu"&gt;&lt;ul&gt;...&lt;/ul&gt;&lt;/div&gt;</code>. The <code>&lt;li&gt;</code> needs to look like <code>&lt;li&gt;&lt;a href="#ELEMENTSNAME"&gt;ELEMENTSNAME&lt;/a&gt;&lt;/li&gt;</code>. When a menu item is clicked any "active" classes in #submenu need to be removed and the clicked Anchor gets class="active".</p>
  
  <p>Here are my results where I got stuck:</p>
  
  <p><strong>1) Get elements:</strong></p>
  
  <pre><code>var optionTexts = [];
  $("A.jqsubmenu").each(function() { optionTexts.push($(this).text()) });
  </code></pre>
  
  <p><strong>2) make list</strong> (once I hopefully have an array) and write into DOM</p>
  
  <pre><code>   var SubmenuArray = ['One', 'Two', 'Three'];
      // GENERATE SUBMENU
          var ObjUl = $('&lt;div id="submenu"&gt;&lt;ul&gt;&lt;/ul&gt;&lt;/div&gt;');
          for (i = 0; i &lt; SubmenuArray.length; i++)
          {
              var Objli = $('&lt;li&gt;&lt;/li&gt;');
              var Obja = $('&lt;a href="#ARRAYITEM"&gt;ARRAYITEM&lt;/a&gt;');
  
          }       // WRITE INTO DOM
          $('#submenuwrap').append(ObjUl);
      }
  </code></pre>
  
  <p><strong>3) CSS-Gimmick</strong></p>
  
  <pre><code>$( document ).ready(function() {
      $( "#submenu A" ).click(function( event ) {
          $( "#submenu A" ).removeClass("active");
          $( this ).addClass("active");
      });
  });     
  </code></pre>
  
  <p>Thanks for your answers and all the best!</p>