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

前端 未结 9 681
既然无缘
既然无缘 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:40

    Firstly, you shouldn't have multiple elements with the same ID on a page - ID should be unique.

    You could just remove the id attribute and and replace it with:

    
    

    and to get an array of the values of task do

    var taskArray = new Array();
    $("input[name=task]").each(function() {
       taskArray.push($(this).val());
    });
    

提交回复
热议问题