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

前端 未结 5 1901
耶瑟儿~
耶瑟儿~ 2021-02-07 00:17

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(         


        
5条回答
  •  北海茫月
    2021-02-07 00:53

    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++){
        alert($(inputs[i]).val());
    }
    

提交回复
热议问题