在下面的代码中,我使用了 json 数组(pedingPLT)将数据加载到下面的 html 表中。这里每个表数据都有一个值。在特定的表数据中,我包含了一个按钮。那么是否有可能为按钮分配多个值(*********),我的意思是通过使用数组。请帮助我
function TSC_document_status_list_table_for_tsc_portal() {
var tableData;
$.post("model/tscAdminView.php", {action: 'TSC_document_status_list_table_for_tsc_portal'}, function (e) {
if (e === undefined || e.length === 0 || e === null) {
tableData = '<tr class="error"><td colspan="4"> No Data Found in database </td></tr>';
$('#TSC_document_status_list_table_for_tsc_portal tbody').html('').append(tableData);
} else {
$.each(e, function (index, pedingPLT) {
index++;
tableData += '<tr>';
tableData += '<td>' + index + '</td>';
tableData += '<td>' + pedingPLT.document_id + '</td>';
tableData += '<td>' + pedingPLT.tsc_accepted_Or_Created_date +'</td>';
tableData += '<td>' + pedingPLT.total_allocated_days + ' days' + '</td>';
tableData += '<td>' + pedingPLT.Expired_date + '</td>';
tableData += '<td> <button class="btn btn-sm btn-alt m-r-5 delete_selected_employee" value="' + ******** + '"><i class="fa fa-trash-o fa-lg"></i> </button>' + pedingPLT.total_quantity +'</td>';
tableData += '<td>' + pedingPLT.Completed_phone_list + '</td>';
tableData += '<td>' + pedingPLT.peding_phone_list + '</td>';
tableData += '</tr>';
});
//Load Json Data to Table
$('#TSC_document_status_list_table_for_tsc_portal tbody').html('').append(tableData);
}
}, "json");
}
最佳答案
按钮的 value
属性的类型为“text”( source ),因此无法向其添加多个值。
也就是说,您可以自由地将其中的 JSON 字符串字符串化为值,并在需要时解析它:
JSON.stringify()
(方法文档:JSON.stringify)
关于javascript - 使用 javascript 和 json 加载表格时如何为按钮分配多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45372457/