0

我有一张桌子。左栏是英文单词,右栏是韩文单词。如何保持行完整,然后随机化列的顺序?例子:

<table>
<colgroup>
  <col width="*" />
  <col width="*" />
</colgroup>
<tbody>
  <tr>
    <td>turn</td>
    <td><strong>설정하다</strong></td>
  </tr>
  <tr>
    <td>turn aside, turn around</td>
    <td><strong>옆으로 비키다&lt;/strong></td>
  </tr>
  <tr>
    <td>turn around</td>
    <td><strong>옆을보다</strong></td>
  </tr>
  <tr>
    <td>hear / listen</td>
    <td><strong>듣다</strong></td>
  </tr>
</tbody>

4

1 回答 1

0

更新:改组trs

var
  trs = document.querySelectorAll('tr'),
  i = trs.length,
  tr;

for (; i > 1; i -= 1) {
  tr = trs.item(Math.floor(Math.random() * i));
  tr.parentNode.appendChild(tr);
}

演示:http: //jsbin.com/ogemec/1/

于 2013-01-14T16:03:33.393 回答