如何在javascript中的“el”元素中编写数据插件?
<input type="text" data-plugin="datepicker" class="form-control" >
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow1' + iteration;
el.style.width = "100%";
el.style.border = "thin solid #E0E0E0";
// how to put in data-plugin="datepicker" in el ?
el.onkeypress = keyPressTest;
cellRight.appendChild(el);
答案 0 :(得分:0)
使用dataset
:
el.dataset.plugin = "datepicker"
答案 1 :(得分:0)