我想在表格中隐藏空单元格.这是我的代码:
$(function() {
$(".empty").each(hideCellIfEmpty);
});
function hideCellIfEmpty() {
var theCell = $(this);
if (theCell.html().length == 0) {
hideSoft(theCell);
}
}
function hideSoft(jQElement) {
jqElement.css('visibility', 'hidden');
}Run Code Online (Sandbox Code Playgroud)
table.empty {
width: 350px;
border-collapse: collapse;
empty-cells: hide;
}
td.empty {
border-style: solid;
border-width: 1px;
border-color: blue;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<table class="empty">
<tr>
<th></th>
<th>Title one</th>
<th>Title two</th>
</tr>
<tr>
<th>Row Title</th>
<td class="empty">value</td>
<td class="empty">value</td>
</tr>
<tr>
<th>Row Title</th>
<td class="empty">value</td>
<td class="empty"></td>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
你可以看到,第二行显示空单元格.但我想隐藏它.而且,我不想用border-collapse:separate.是否可以使用隐藏空单元格border-collapse:collapse?我也想知道为什么这会显示空单元格.
PS使用border-collapse: separate …
我正在尝试在markdown中生成一个没有列标题的表,我在Internet上找到的每个样本都使用列标题.我想要的表是M x 2.
我正在为 Azure DevOps wiki 页面创建 HTML 表(我需要使用 HTML 表而不是 Markdown 表来实现正确的颜色格式)。在此表中,我需要创建到其他 wiki 页面的链接。Markdown 中链接 wiki 页面的格式如下:
[text to display](/parent-page/child-page). 但是,我不知道如何使用 HTML 标签而不列出 URL: 来执行此操作<a href="absolute or relative URL">text to display</a>。我想避免链接 URL,因为我通过使用脚本生成.md包含所有链接的文件来创建 wiki 页面,并且与 URL 链接需要使用页面 ID 号和其他信息,而不仅仅是名称维基页面的内容,使该过程变得更加困难。
我发现您可以在 Azure DevOps 中将 Markdown 嵌套在 HTML 中,但必须在 HTML 元素和 Markdown 之间包含一个空行。但是,添加此空行似乎会弄乱表中所有后续行的格式。以下是 Azure DevOps wiki 页面中 HTML 表格的格式。
<table>
<tr>
<th>Table Header</th><th>Table Header</th>
</tr>
<tr>
<td>
[Other wiki page](/parent-page/child-page)
</td><td>Table cell 2</td>
</tr>
<tr>
<td>Table cell 3</td><td>Table cell …Run Code Online (Sandbox Code Playgroud)