title: How to retrieve value from elements in array using jQuery?
body: <p>I have multiple input fields like so:</p>
  
  <pre><code>&lt;input type="text" name="card[]"&gt;
  &lt;input type="text" name="card[]"&gt;
  &lt;input type="text" name="card[]"&gt;
  </code></pre>
  
  <p>Users can add or remove these fields as required, therefore the name of the fields is an array. 
  To get length of the array, this works fine:</p>
  
  <pre><code>var n = $("input[name^= 'card']").length;
  </code></pre>
  
  <p>How can I read value from the array?</p>
  
  <p>I've tried this which didn't work:</p>
  
  <pre><code>var n = $("input[name^='card']").length;
  var array = $("input[name^='card']");
  for(i=0;i&lt;n;i++)
  {
   card_value=  array[i].val();
   alert(card_value);
  }
  </code></pre>
  
  <p>This didn't work either:</p>
  
  <pre><code>var n = $("input[name^='card']").length;
  
  for(i=0;i&lt;n;i++)
  {
   card_value=  $("input[name^='card["+i+"]']").val();
   alert(card_value);
  }
  </code></pre>
  
  <p>How can I read value from this array?
  Help!</p>