How to get all value from input

I have the following sample HTML:

<table id="modem_list">
   <tr class="input_1" name="modem">
      <td>iPad 1<input type="hidden" value="1" class="output_1"></td>
   <tr class="input_2" name="modem">
      <td>iPad 2<input type="hidden" value="2" class="output_2"></td>
   <tr class="input_3" name="modem">
      <td>iPad 3<input type="hidden" value="3" class="output_3"></td>

And jQuery script:

val = [];
   val[i] = jQuery(this).val();

I am getting an error when using this script, how to fix it?


try like so

var val = [];
  1. you wrote ouput instead of output
  2. wrap the attribute value in quotes ""
  3. (and using push there's no need to use an explicit index for the array)

While the other answers are perfectly valid, here's a slightly shorter alternative using map, with get to return an array:

var val = jQuery('input[class^=output_]').map(function() {
    return this.value;

Notice that in your code you have written 'ouput' instead of 'output'.

you could have used the same class, you are using wrong class name try:

var valArr = [];

You can use:

var val= $("#modem_list :input").serializeArray();

Look, you have


instead of


you can also write this

val = [];

Need Your Help

Pass custom class data between view controllers in Swift

ios uitableview class swift viewcontroller

I have two view controllers one that contains a tableview and another that contains the page to show following selection of a particular row.

What should happen when a reference is deleted?

.net dll reference

I have a 3.5 application which references a dll (abc.dll, also in .net 3.5)