【发布时间】:2017-10-31 09:58:46
【问题描述】:
我有一个表格,每一行都包含一个 select2,我想从每个表格中获取数据并将其存储到数组中。下面是我将使用的代码,不确定它是否正确。
// event on each form change re-get the values
$("#main").bind("keyup change", function (e) {
$('#form > tbody > tr').each(function (i) {
// get the data for each select
// add it to array and use after loop for some logic
// not sure if need this event here : select2:select
// also the selector might be not in the node of current tr?
$('.selector').on("select2:select", function (e) {
var data = $(this).select2('data');
// push to array ?? data[0].custom_data
});
});
// logic from array would be here
});
【问题讨论】:
-
你是否运行了这段代码,如果是,你得到了什么错误?更多细节会有所帮助
-
好吧,我只有一行:]
标签: jquery jquery-select2 jquery-select2-4