我有一個asp.net gridview,我在所選的複選框上使用'onclick'隱藏和顯示列。 隱藏的列在IE中顯示正常,但單擊時它們在Chrome,Firefox中重疊。我必須錯過一些東西,就好像他們被添加到同一列中一樣。由於我是新手,我可以發佈截圖。JavaScript顯示隱藏功能佈局問題firefox chrome
任何幫助非常感謝。
function showColumn(r,grid) {
rows = document.getElementById("GridView1").rows;
drop = document.getElementById(grid);
if (drop.checked == true) {
for (i = 0; i < rows.length; i++) {
rows[i].cells[r].style.display = "block";
}
}
else if (drop.checked == false) {
for (i = 0; i < rows.length; i++) {
rows[i].cells[r].style.display = "none";
}
}
}
<p>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="showColumn(2,'CheckBox1')"
Text="Show Option Name" />
</p>
<p>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="showColumn(1,'CheckBox2')"
Text="Show ID" />
</p>
這很好用,它可以根據需要正確運行。謝謝。 – stuggyg