title: Is there a way to target HTML in an Array with jQuery?
body: <p>I have an array:</p>
  <pre><code>wireholder.wires[]
  </code></pre>
  <p>This array holds HTML <code>tr</code> elements with <code>td</code> children in each iteration:</p>
  <pre><code>wireholder.wires[1] = 
  &lt;tr class=&quot;trClass&quot; id=&quot;blah&quot;&gt;
      &lt;td class=&quot;tdClass0&quot;&gt;
           &lt;select class=&quot;selectClass&quot;&gt;
               &lt;option value=&quot;1&quot;&gt;Option1&lt;/option&gt;
               &lt;option value=&quot;2&quot;&gt;Option2&lt;/option&gt;
               &lt;option value=&quot;3&quot;&gt;Option3&lt;/option&gt;
           &lt;/select&gt;
      &lt;/td&gt;
      &lt;td class=&quot;tdClass1&quot;&gt;
           &lt;input class=&quot;inputClass1&quot; type=&quot;text&quot; /&gt;
      &lt;/td&gt;
      &lt;td class=&quot;tdClass2&quot;&gt;
           &lt;input class=&quot;inputClass2&quot; type=&quot;text&quot; /&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  <p>I want to be able to target the class names in this arrays iteration.</p>
  <p>Something like <code>$(wireholder.wires[i].classNameHere)</code> would be exactly what i'm after.</p>
  <p>Has anyone heard of any ways to do something like this?</p>
  <hr />
  <h2>Solution</h2>
  <pre><code>for(i=0;i&lt;oldElement.length;i++){
      if($(node).find('.wire_selector_' + row).length){
          var oldWire = $(node).find('.wire_selector_' + row).val();
      }
      if($(node).find('.wire_length_' + row).length){
          var oldLength = $(node).find('.wire_length_' + row).val();
      }
      if($(node).find('.wire_retail_' + row).length){
          var oldPrice = $(node).find('.wire_retail_' + row).val()*100;
      }
  }
  </code></pre>
  <hr />
  <h2>For vol7ron</h2>
  <pre><code>function DomFactory() 
  {
      this.buildElement = function(elementType, props) {
          var el = document.createElement(elementType);
          for (var prop in props) {
              el.setAttribute(prop,  props[prop]);
          }
          return el;
      };
  
      this.buildTextNode = function(nodeData) {
          var node = document.createTextNode(nodeData);
          return node;
      };
  }
  </code></pre>
  <p>Then using DomFactory:</p>
  <pre><code>var dom_builder = new DomFactory();
          var part_stub = dom_builder.buildElement(&quot;tr&quot;, {'class': &quot;wiring_details_&quot; + Wireholder.wires.length + &quot;-&quot; + part_id + &quot;-&quot; + zone_id, 'id': &quot;wiring_rows_&quot; + Wireholder.wires.length});
          var part_td = dom_builder.buildElement(&quot;td&quot;, {'colspan': '2'});
          var wire_type = dom_builder.buildTextNode(&quot;Wire Type: &quot;);
          var select_wire = dom_builder.buildElement(&quot;select&quot;, {'class': 'wire_selector_' + Wireholder.wires.length, 'name': 'select_wire_' + Wireholder.wires.length});
          var wireValues = [&quot;Select wire..&quot;, &quot;14/2&quot;, &quot;14/4&quot;, &quot;16/4&quot;, &quot;16/2&quot;, &quot;RG6&quot;, &quot;CAT5&quot;, &quot;RG59&quot;, &quot;LVT&quot;, &quot;CAT6&quot;, &quot;HDMI&quot;, &quot;Shielded CAT6&quot;];
          var length_stub = dom_builder.buildElement(&quot;td&quot;, {'colspan': '2'});
          var wire_length = dom_builder.buildTextNode(&quot;Length: &quot;);
          var wire_length_input = dom_builder.buildElement(&quot;input&quot;, {'type': &quot;text&quot;, 'class': 'wire_length_' + Wireholder.wires.length, 'name': 'wire_length_' + Wireholder.wires.length, 'value': '1'});
          var retail_stub = dom_builder.buildElement(&quot;td&quot;, {'colspan': '2'});
          var wire_retail_price = dom_builder.buildTextNode(&quot;Retail Price: &quot;);
          var wire_retail_input = dom_builder.buildElement(&quot;input&quot;, {'type': &quot;text&quot;, 'class': 'wire_retail_' + Wireholder.wires.length, 'name': 'wire_retail_' + Wireholder.wires.length, 'value': '0'});
          var total_stub = dom_builder.buildElement(&quot;td&quot;, {'colspan': '2', 'class': &quot;wire_total&quot;});
          var add_button = dom_builder.buildElement(&quot;a&quot;, {'href': &quot;#&quot;, 'class': &quot;add-button&quot;, 'id': &quot;wiring_button_&quot; + Wireholder.wires.length});
          var add_wire = dom_builder.buildTextNode(&quot;Add Wire&quot;);
          var wire_id = dom_builder.buildElement(&quot;input&quot;, {'type': &quot;hidden&quot;, 'id': 'wire_id_&lt;?php echo $part-&gt;id; ?&gt;', 'name': 'wire_id_&lt;?php echo $part-&gt;id; ?&gt;', 'value': '&lt;?php echo $part-&gt;wire_id; ?&gt;'});
          that.appendChild(part_stub);
          Wireholder.wires.push(part_stub);
  </code></pre>
  <p>There is more but you get the idea...</p>