我应该使用< table>或< ul>? [英] Should I use <table> or <ul>?

查看:155
本文介绍了我应该使用< table>或< ul>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用javascript来呈现动态数据,应该显示为n行m列。我听说过使用表的不良影响,但不能证明我自己,为什么我应该/不应该使用表。你能否推荐选择替代方案的最佳实践。我在所有< ul> 是替代,我如何使它看起来像一个表?



如果我使用表,我不能对表行进行动画。考虑这一点,请建议替代方案。

解决方案

您不应使用表格作为布局。将表用于表格数据是完全合理的。如果你有n行和m列,这听起来很可怕很多,如表格数据,这将是适当的使用< table> 。 >

至于动画化表格行,如果这意味着使用javascript动态添加和删除表格中的行,这是支持的。请参见表方法的DOM参考。它支持 insertRow() deleteRow()


I have to render dynamic data using javascript which should be displayed as n rows, m columns. I have heard of ill-effects of using tables but cannot justify on my own as to why I should/should-not use tables. Can you reason the best practice in choosing the alternative for the requirement. I at all <ul> is the alternative, how do I manage to make it look like a table?

If I use tables, I cannot animate table rows. Keeping this consideration, please suggest the alternative.

解决方案

You should not use tables for layout. It's perfectly reasonable to use tables for tabular data. If you have "n rows" and "m columns", that sounds an awful lot like tabular data and it would be appropriate to use a <table>.

As far as "animating" table rows, if by that you mean dynamically adding and removing rows from a table using javascript, that is supported. See the DOM Reference for table methods. It supports operations such as insertRow() and deleteRow().

这篇关于我应该使用&lt; table&gt;或&lt; ul&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆