Question: I am trying to get the values of each of the input field that are under same set. Below is my code:

Input field 1:

```
<input type="text" maxlength="255" name="amount[]" >

```

Input field 2: 

```
<input type="text" maxlength="255" name="amount[]" >

```

and so on....the number of fields are variable. 

Now I want to get the values the user typed in each of the field that is named . How to do that in jquery?

I have tried following code but it returns nothing:

```
$("input[name=amount[]]").val();

```

Answer: 
Since there are multiple element with same name you need indexing:

```
$("input[name='amount[]']")[0].value;

```

[Here is demo](http://jsfiddle.net/zaheerahmed/WuU7H/)

and for getting all elements values:

```
$("input[name='amount[]']").each(function (i,v) {
    alert(this.value);
});

```

[Here is demo](http://jsfiddle.net/zaheerahmed/WuU7H/1/)
Try to pass the attribute value as a `string` since `[` and `]` are meta-characters,

```
var values = $("input[name='amount[]']")
                  .map(function(){ return $(this).val() })
                    .get().join('');

```

[DEMO](http://jsfiddle.net/hy7QS/)
----------------------------------