title: Pushing arrays based on each row inputs dynamically
body: <p>Based on my code I want to push each row's inputs to each array. If it is row1, it should push all the input values of row 1 to array <code>a1</code>. The second row's inputs should be pushed to array <code>a2</code> and so on. </p>
  
  <p>This is mainly for performance optimization of my code since the rows of my real code are 20+ and I am trying to do it like below but without success.</p>
  
  <p>I want to be able to know each row's data  (for validation purpose)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#check').click(function(event){
  event.preventdefault;
    var a1=[];var a2=[];
    $("[id^=row]").find("td input").each(function(i) { a[i].push(this.value); });
    $('#output').html('&lt;h4&gt;Pushed arrays:&lt;/h4&gt;a1: ['+a1 +'] &lt;br/&gt; a2: ['+a2+']');
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table&gt;
      &lt;tr id="row1"&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" value="0" size="4"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" size="4"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" size="4"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" value="0" size="4"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="row2"&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" size="4"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" value="1" size="4"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" value="0" size="4"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input  type="text" size="4"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;button id="check"&gt;Check Values&lt;/button&gt;
  &lt;div id="output"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>