GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing uk.javascript.info — Sortable table

  • Підручник
  • Браузер: документ, події, інтерфейси
  • Вступ до подій
  • Делегування подій
назад до уроку

Sortable table

важливість: 4

Make the table sortable: clicks on <th> elements should sort it by corresponding column.

Each <th> has the type in the attribute, like this:

<table id="grid">
  <thead>
    <tr>
      <th data-type="number">Вік</th>
      <th data-type="string">Ім’я</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>5</td>
      <td>Іван</td>
    </tr>
    <tr>
      <td>12</td>
      <td>Ганна</td>
    </tr>
    ...
  </tbody>
</table>

У наведеному вище прикладі перший стовпець містить числа, а другий – рядки. Функція сортування повинна обробляти сортування відповідно до типу.

Повинні підтримуватися лише типи "string" та "number".

Робочий приклад:

P.S. Таблиця може бути великою, з будь-якою кількістю рядків і стовпців.

Відкрити пісочницю для завдання.

Відкрити рішення в пісочниці.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.