javascript - 表格标题未与 ajax 调用的表格行对齐
问题描述
结果我使用了 ajax 调用来检索行的数据。我的结果没有显示表格的正确格式。这些行出现在标题的第一列中。我在正文中添加了表头,所以我不确定是否是因为这个。
请帮助我使标题和行对齐。提前致谢。
这是我的一段代码:
$(document).ready(function() {
$.ajax({
url: "/otcs/livelink.exe/open/WebReport1",
dataType: 'html',
async: true,
success: function(result) {
var $response = $(result);
// console.log(result)
var a = $(result).find("tr.GO").clone();
$("#div1").html(a);
}
});
});
function Display1() {
$("#TableHeading1").toggle();
$("#div1").toggle();
}
table.Table {
align: center;
margin-right: 50px;
font-family: calibri;
border-collapse: collapse;
width: 100%;
}
#TableHeading1>th {
background-color: lightgrey;
font-family: times new roman;
font-size: 18px;
border-style: double;
}
.GO>td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
border: 1px solid black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="hide" style="display:none"></div>
<button type="button" style="font-family:calibri;font-size:25px;background-color:Teal;color:white;width:150px;height:50px;cursor:pointer;" onclick="Display1();">GO</button>
<div>
<table class="Table">
<tr id="TableHeading1" style="display:none">
<th>Employee ID</th>
<th>Name</th>
<th>Mail address</th>
<th>Phone Number</th>
<th>Designation</th>
</tr>
<tr id="div1" style="display:none"></tr>
</table>
</div>
解决方案
推荐阅读
- python - 从一个 Socket 接收两个函数
- python - 在python中使用正则表达式获取特定文本的左右文本
- r - 未找到函数中的 R 对象
- java - 使用正则表达式查找 Json 值:匹配字符串,然后是任意数量的字符,然后是第二个匹配字符串之后的值
- java - Android/Java:如何从 Canvas 中提取位图?
- python - 如何在 Linux Ubuntu 16.04 中使用 Pip3 安装 Python 3.6 模块?
- javascript - 如何在变量中引用站点上的键入文本
- javascript - 为什么 JavaScript 函数返回未定义?
- android - 如何在 Android 上的 Xamarin.Forms.Shell 应用程序中的 TabBar 更改后防止 WebView 重新加载?
- php - Docker-compose:防止 PECL 安装停止构建过程