jiaoye6789
2017-08-15 06:04
采纳率: 70.4%
浏览 2.1k
已采纳

JS合并数据相同单元格

合并前

 <table>
  <thead>
    <tr>
    <th>房屋编号<th>
    <th>房屋名称<th>
    <th>房屋状态<th>
    <th>设备名称<th>
    <th>设备状态<th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>001</td>
    <td>A</td>
    <td>正常</td>
    <td>电视</td>
    <td>正常</td>
    </tr>
    <tr>
    <td>001</td>
    <td>A</td>
    <td>正常</td>
    <td>冰箱</td>
    <td>正常</td>
    </tr>
    <tr>
    <td>001</td>
    <td>A</td>
    <td>正常</td>
    <td>空调</td>
    <td>正常</td>
    </tr>
    <tr>
    <td>002</td>
    <td>B</td>
    <td>正常</td>
    <td>电视</td>
    <td>正常</td>
    </tr>
        <tr>
    <td>002</td>
    <td>B</td>
    <td>正常</td>
    <td>电视</td>
    <td>冰箱</td>
    </tr>
    </tbody>
 </table>

想要得到合并后的样子

 <table>
  <thead>
    <tr>
    <th>房屋编号<th>
    <th>房屋名称<th>
    <th>房屋状态<th>
    <th>设备名称<th>
    <th>设备状态<th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td rowspan="3">001</td>
    <td rowspan="3">A</td>
    <td rowspan="3">正常</td>
    <td>电视</td>
    <td>正常</td>
    </tr>
    <tr>
    <td>冰箱</td>
    <td>正常</td>
    </tr>
    <tr>
    <td>空调</td>
    <td>正常</td>
    </tr>
    <tr>
    <td rowspan="2">002</td>
    <td rowspan="2">B</td>
    <td rowspan="2">正常</td>
    <td>电视</td>
    <td>正常</td>
    </tr>
    <tr>
    <td>电视</td>
    <td>冰箱</td>
    </tr>
    </tbody>
 </table>

1条回答 默认 最新

相关推荐 更多相似问题