简单的问题,我在JS中很少。
在添加表格按钮中,我添加新表并将其附加到.tab-content
div中。 (无需显示按钮代码)。
if (typeof (Storage) !== "undefined") {
if (localStorage.Index) {
localStorage.Index = Number(localStorage.Index) + 1;
} else {
localStorage.Index = 1;
}
} else {
}
function getTableList() {
var addTable = '<div class="tab-pane" id="folder' + localStorage.Index + '">' +
'<div class="zf-table">' +
'<table id="table' + localStorage.Index + '" class="table table-bordered table-hover myFade">' +
'<thead>' +
'<tr>' +
'<th style="border-color:rgb(221, 221, 221);"></th>' +
'<th>Audience Name</th>' +
'<th>Type</th>' +
'<th>Size</th>' +
'<th>Date Created</th>' +
'<th>Action</th>' +
'</tr>' +
'</thead>' +
'</table>' +
'</div>' +
'</div>';
return addTable;
}
let newtableHTML = getTableList();
$('.tab-content').append(newtableHTML);
如何将表ID存储到console.log中?
<table id="table' + localStorage.Index + '" class="table table-bordered table-hover myFade">
将显示日志
table1
table2
当用户添加新表时。
答案 0 :(得分:0)
只需在getTableList函数中添加一条日志语句......
function getTableList() {
console.log("table" + localStorage.Index);
// rest of your function...
这样每次调用日志时输出表id。
答案 1 :(得分:0)
console.log('table' + localStorage.Index)