Selecting array of inputs

Selecting array of inputs

Hello,

I have multiple input fields in my form with name attribute set to "firstname[]":

<p>
  <input type="text" name="firstname[]"/>
  <input type="text" name="lastname[]"/>
</p>
<p>
  <input type="text" name="firstname[]"/>
  <input type="text" name="lastname[]"/>
</p>


the problem is that i cannot easily select the objects.
this does not work and i cannot find any solution in jquery reference:
$('input [name=firstname]').val()


Is it possible to select an array like that in jquery? or should i give class or id for each input?