将标准 HTML table元素转换为Tabulator表

可以将标准 HTML 表格元素转换为Tabulator,在创建表格时将所有数据直接从表格拉入制表器。

如果要从表中提取列标题,则需要确保已定义thead元素,每个列标题都在th元素。如果指定width属性,则将其设置为制表器中列的宽度。

以这种方式创建表时,您可以设置任何标准制表器选项,以便轻松转换旧表以利用制表器提供的众多功能。

标准 HTML 表格:

NameAgeGenderHeightFavourite ColorDate of Birth
Billy Bob12male1red22/04/1994
Mary May1female2blue14/05/1982

转换为制表器:

 

源代码

.HTML

<table id="example-table">
    <thead>
        <tr>
            <th width="200">Name</th>
            <th tabulator-hozAlign="center">Age</th>
            <th>Gender</th>
            <th>Height</th>
            <th width="150">Favourite Color</th>
            <th>Date of Birth</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Billy Bob</td>
            <td>12</td>
            <td>male</td>
            <td>1</td>
            <td>red</td>
            <td>22/04/1994</td>
        </tr>
        <tr>
            <td>Mary May</td>
            <td>1</td>
            <td>female</td>
            <td>2</td>
            <td>blue</td>
            <td>14/05/1982</td>
        </tr>
    </tbody>
</table>

JavaScript

 var table = new Tabulator("#example-table", {});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值