Search code examples

Get the values of all inputs with same class as an array

I have a group of inputs and I want to get the value of each one in array form or in any way that you will suggest. I am not very good at arrays.

$(elemnt).each(function(index, element) {

the above line of code alert right thing for me but for a single input only but I have multiple inputs with class="spocName" so I want to get values of all and so that I could then save each in DB table in seperate rows.


  • If all your inputs share the same class say "class1" then you can select all such inputs using this

    var inputs = $(".class1");

    Then you can iterate over the inputs any way you want.

    for(var i = 0; i < inputs.length; i++){