0
我在玉这样一个隐藏的输入字段:添加到HTML输入数组
input(name='saintForm[quotes][]', type='hidden')
我想使用jQuery从动态无序列表添加到该数组,但不知道如何。这是我的失败尝试:
$('#form').on('submit', function(e){
e.preventDefault();
$('.quote').each(function (i){
var item = $(this).text().replace(' (x)','');
$("input[name='saintForm[quotes][]']").push(item);
});
this.submit();
});
你没有数组,你有一个数组式的jQuery对象,它没有'push'方法。你可能在寻找jQuery的'add()'方法,但不知道'item'是什么,这是不可能知道的? – adeneo 2014-09-24 18:54:29
对不起,添加了该项目。我尝试使用add(),但服务器上的结果仍显示空白 - 引号:[''] – 2014-09-24 18:57:52
正如@adeneo提到的,您没有数组。我认为唯一的方法就是遍历引号并逐个添加到输入值。 – 2014-09-24 19:04:23