如何在dom元素中插入输入标签data-plugin?

时间:2016-05-09 03:17:52

标签: javascript html

如何在javascript中的“el”元素中编写数据插件?

HTML

<input type="text" data-plugin="datepicker" class="form-control" >

javscript

  // 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);

2 个答案:

答案 0 :(得分:0)

使用dataset

el.dataset.plugin = "datepicker"

答案 1 :(得分:0)