jsp中比较两个表的列宽
我目前在从我的主 jsp 进行 ajax 调用后包含一个表。
一切顺利。但我的问题是假设我有一个像这样的表:
<table id="onMainpage">
<THEAD>
<tr>
<td> My Entries</td>
<td> My Entries</td>
<td> My Entries</td>
</tr>
</THEAD>
<TBODY>
<tr>
<td> My Entries</td>
<td> My Entries</td>
<td> My Entries</td>
<tr>
</TBODY>
</table>
在进行 ajax 调用后,我将得到以下信息:
<TBODY>
<tr>
<td> My Entries</td>
<td> My Entries</td>
<td> My Entries</td>
<tr>
</TBODY>
要点是我将仅替换 数据,当我这样做时,该表未对齐。即THEAD 和TBODY 之间的列长度不同。
我们怎样才能做到这一点?请告诉我。
I'm currently including a table after making an ajax call from my main jsp.
Its coming up fine. But my question is suppose I have a table like :
<table id="onMainpage">
<THEAD>
<tr>
<td> My Entries</td>
<td> My Entries</td>
<td> My Entries</td>
</tr>
</THEAD>
<TBODY>
<tr>
<td> My Entries</td>
<td> My Entries</td>
<td> My Entries</td>
<tr>
</TBODY>
</table>
After making ajax call I will get the following:
<TBODY>
<tr>
<td> My Entries</td>
<td> My Entries</td>
<td> My Entries</td>
<tr>
</TBODY>
Point is that I will be replacing the <TBODY>
data only and when I do that, the table is misaligned.i.e. the column length varies between THEAD and TBODY.
How can we accomplish this? Please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是因为您获得的列数不同,或者数据中可能存在空单元格,也请在其他浏览器中检查!
最佳解决方案:使用 CSS 修复宽度!
否则:
将呈现为空白单元格,如果在表属性中将空单元格设置为 false,则会减少列数。检查服务器响应中某些数据是否为空。
另一种可能性是,某些未闭合的标签或数据的位置未对齐。检索到响应后检查元素。
This could be either because u r getting different number of column or there could be empty cell in data, check in other browsers too!!
Best Solution: Fix width using CSS!!
Else:
<td></td>
will be rendered as blank cell and if empty-cells is set to false in table property, it will reduce number of columns. Check if some data is null in server response.Another possibility is, some unclosed tag or misaligned placement of data. Inspect Elements once u have retrieved the response.
您可能最初在 TBODY 中添加更多/更少的列,否则它不应该错位。
You may be adding more/less column in TBODY intialy it has other wise it should not misalign.