如何比较 innerHTML 字符串?
How to compare innerHTML string?
是否有可能获得 "fusiontabledata" 和 "fusiontabledata2" 的结果,比较两者并生成第三个 "sidebar" 仅显示重复项?
document.getElementById('sidebar_1').innerHTML = fusiontabledata;
document.getElementById('sidebar_2').innerHTML = fusiontabledata2;
function getData_From(response) {
FTresponse = response;
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
fusiontabledata = "<table><tr>";
fusiontabledata += "</tr><tr>";
for (i = 0; i < numRows; i++) {
for (j = 0; j < numCols; j++) {
fusiontabledata += "<td>" + response.getDataTable().getValue(i, j) + "</td>";
}
fusiontabledata += "</tr><tr>";
}
fusiontabledata += "</table>"
document.getElementById('sidebar_1').innerHTML = fusiontabledata;
}
function getData_To(response) {
FTresponse = response;
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
fusiontabledata2 = "<table><tr>";
fusiontabledata2 += "</tr><tr>";
for (i = 0; i < numRows; i++) {
for (j = 0; j < numCols; j++) {
fusiontabledata2 += "<td>" + response.getDataTable().getValue(i, j) + "</td>";
}
fusiontabledata2 += "</tr><tr>";
}
fusiontabledata2 += "</table>"
document.getElementById('sidebar_2').innerHTML = fusiontabledata2;
}
innerHTML
是一个字符串,你可以很容易地比较两个字符串。
在两个函数的末尾执行,当字符串相等时,将结果添加到第3个侧边栏:
if(document.getElementById('sidebar_1').innerHTML
===
document.getElementById('sidebar_2').innerHTML){
document.getElementById('sidebar_3')
.appendChild(document.getElementById('sidebar1')
.firstChild.cloneNode(true));
}
是否有可能获得 "fusiontabledata" 和 "fusiontabledata2" 的结果,比较两者并生成第三个 "sidebar" 仅显示重复项?
document.getElementById('sidebar_1').innerHTML = fusiontabledata;
document.getElementById('sidebar_2').innerHTML = fusiontabledata2;
function getData_From(response) {
FTresponse = response;
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
fusiontabledata = "<table><tr>";
fusiontabledata += "</tr><tr>";
for (i = 0; i < numRows; i++) {
for (j = 0; j < numCols; j++) {
fusiontabledata += "<td>" + response.getDataTable().getValue(i, j) + "</td>";
}
fusiontabledata += "</tr><tr>";
}
fusiontabledata += "</table>"
document.getElementById('sidebar_1').innerHTML = fusiontabledata;
}
function getData_To(response) {
FTresponse = response;
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
fusiontabledata2 = "<table><tr>";
fusiontabledata2 += "</tr><tr>";
for (i = 0; i < numRows; i++) {
for (j = 0; j < numCols; j++) {
fusiontabledata2 += "<td>" + response.getDataTable().getValue(i, j) + "</td>";
}
fusiontabledata2 += "</tr><tr>";
}
fusiontabledata2 += "</table>"
document.getElementById('sidebar_2').innerHTML = fusiontabledata2;
}
innerHTML
是一个字符串,你可以很容易地比较两个字符串。
在两个函数的末尾执行,当字符串相等时,将结果添加到第3个侧边栏:
if(document.getElementById('sidebar_1').innerHTML
===
document.getElementById('sidebar_2').innerHTML){
document.getElementById('sidebar_3')
.appendChild(document.getElementById('sidebar1')
.firstChild.cloneNode(true));
}