javascript - 切换表格的显示:不是第一列
问题描述
我有一个表格,开始时只显示第一列:
#tablegrid tr td:not(:first-child) {
display:none;
}
单击按钮时如何显示所有其他列?
以下是我尝试过的:
$(document).on('click', '#revealbutton', function() {
$("<style> #tablegrid tr td:not(:first-child) { display:show; } <\/style>").appendTo("head");
});
解决方案
编辑您的display:table-cell
代码display: show
$(document).on('click', '#revealbutton', function() {
$("<style> #tablegrid tr td:not(:first-child) { display:table-cell; } <\/style>").appendTo("head");
});
#tablegrid tr td:not(:first-child) {
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="tablegrid">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
<button id="revealbutton">click me</button>
推荐阅读
- python - 如何使用 django_heroku 将 Django(通过 Anaconda)部署到 Heroku
- mysql - 如何杀死mysql进程
- delphi - 如何在Delphi上实时应用PNG图像在TImage组件中的Anti Aliasing?
- python - 如何将 lambda 函数应用于 pandas 数据框中的某些行并创建新列
- java - gPRC截止日期的默认值是什么(java)
- python - slpit(',') 不定字符串长度并将元素分配给变量的最佳方法
- vba - 查找和替换功能自动将单元格格式化为日期
- python - 学习使用 python SSH 进入交换机
- pypdf2 - 自动化无聊的东西 Ch13 PyPDF2:pdfReader 未定义
- google-cloud-storage - 挂载存储桶时,不会显示从另一个存储桶中复制的具有“gsutil cp”的 Google 存储存储桶内容