我试图让 js 脚本使用 for 循环创建一些标签,但我收到错误 Object # has no method 'createElement'
它的功能如下:
function tabListRefresh() {
// Get Container
var container = document.getElementById("tabListContainer");
// Clear container
container.innerHTML = "";
// Create tags
for( var k=0; k<tabs.length; k++ ) {
// Create div tag
var div = container.createElement("div");
div.setAttribute("class", "tab");
// Include title into tag
div.innerHTML = tabs[k][0] + " ";
// Create closetab-icon
var closebtn = div.createElement("button");
div.setAttribute("type", "button");
div.setAttribute("class", "closetab");
closebtn.innerHTML = "×";
}
/* XML Structure:
<div class="tab">
Dashboard
<button type="button" class="closetab">×</button>
</div>
*/
}