是否可以在我的网页上单击菜单中的一个按钮,出现一个表,而单击另一个按钮,它将用不同的数据替换该表为另一个表?
我尝试了不同的可能性,尽管它可以工作,但不能代替桌子。
Set rnge = Selection.SpecialCells(xlCellTypeVisible)
For Each area In rnge.Areas
For i = 1 To area.Rows.Count
x = area.Cells(i, 5).Value
y = area.Cells(i, 6).Value
Write #1, x, y
Next i
Next
答案 0 :(得分:2)
document.getElementById("btn1").addEventListener("click", function(){
document.getElementById("table1").style.display = "block";
document.getElementById("table2").style.display = "none";
});
document.getElementById("btn2").addEventListener("click", function(){
document.getElementById("table2").style.display = "block";
document.getElementById("table1").style.display = "none";
});
<button id="btn1">button 1</button>
<button id="btn2">button 2</button>
<table id="table1" style="width:100%;display:none">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
</table>
<table id="table2" style="width:100%;display:none">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
答案 1 :(得分:0)
您的问题的示例代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Appear and Disappear</title>
</head>
<body>
<nav>
<button onclick="showTable1()">showTable1</button>
<button onclick="showTable2()">showTable2</button>
</nav>
<table id='table1' style="display:none">
<tr>
<th>Table Name</th>
</tr>
<tr>
<td>
It's table1
</td>
</tr>
</table>
<table id='table2' style="display:none">
<tr>
<th>Table Name</th>
</tr>
<tr>
<td>
It's table2
</td>
</tr>
</table>
<script>
function showTable1() {
document.getElementById("table1").style.display = "block";
document.getElementById("table2").style.display = "none";
} function showTable2() {
document.getElementById("table1").style.display = "none"; document.getElementById("table2").style.display = "block";
}
</script>
</body>
</html>