How to get an Array with jQuery, multiple <input> with the same name

前端 未结 9 682
既然无缘
既然无缘 2020-11-28 19:02

I have a form where users can add input fields with jQuery.


After submitting the

9条回答
  •  我在风中等你
    2020-11-28 19:22

    Using map:

    var values = $("input[id='task']")
                  .map(function(){return $(this).val();}).get();
    

    If you change or remove the id (which should be unique), you may also use the selector $("input[name='task\\[\\]']")

    Working example: http://jsbin.com/ixeze3

提交回复
热议问题