我正在尝试添加带有
Bootstrap Table
的 Javascript
表标签。表标签的参数之一是 data-pagination
。由于-
,这种添加方法失败了。
我该如何解决这个问题?
所需输出:
<table id="mytable" data-pagination="true" class="table table-striped"></table>
我的代码:
var table_div = document.createElement('table');
table_div.id = 'mytable';
table_div.className = "table table-striped";
table_div.data-pagination = "true";
document.body.appendChild(table_div);
dataset
,例如:
table_div.dataset.pagination = true;
代码:
var table_div = document.createElement('table');
table_div.id = 'mytable';
table_div.className = "table table-striped";
table_div.dataset.pagination = "true";
document.body.appendChild(table_div);
console.log(document.body.innerHTML)
table_div.setAttribute('data-pagination', 'true')