我想在表格中显示一个json数据数组。在每组记录中,我想添加一个日期选择器和一个按钮。 现在,如果我单击该按钮,我希望将数据贴图更改为输入字段。
示例 - 数据 - [ { " name":" sourabh", "电话":" 255888888" }, { " name":" sourabh", "电话":" 255888888" }];
答案 0 :(得分:0)
在就绪功能结束时使用方法
POST

$(document).ready(function () {
var status = [
{
"id": 1,
"name": "sourabh",
"phone": "811880",
"email": "sourabhgrg713@gmail.com"
},
{
"id": 6,
"name": "sourabh",
"phone": "255888888",
"email": "Sourabhgrg713@gmail.com"
},
{
"id": 6,
"name": "sourabh",
"phone": "255888888",
"email": "Sourabhgrg713@gmail.com"
},
{
"id": 6,
"name": "sourabh",
"phone": "255888888",
"email": "Sourabhgrg713@gmail.com"
}];
var len = status.length;
var x = '<input type="date" class="dt datepicker">';
var y = '<button class="make waves-effect waves-light btn" type="button">';
data = "";
if (len > 0) {
for (var i = 0; i < len; i++) {
data = data + "<tr><td>" + status[i].name + "</td><td>" + status[i].phone + "</td><td>" + x + "</td><td>" + y + "</td><tr>";
}
}
$("#mytable tbody").append(data);
$('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 15 // Creates a dropdown of 15 years to control year
});
});
&#13;