トップへ(mam-mam.net/)

JavaScript Table Drag and Drop Example|Reorder HTML Table Rows Easily

Japanese

Drag and Drop Table Rows in JavaScript|Reorder, Copy, and Delete Rows Easily

This page provides a JavaScript table drag and drop example that allows you to reorder HTML table rows by dragging.
Using the lightweight script mamdragdrop.js, you can also enable row copy (Ctrl + Drag) and row delete (Alt + Click).

// Settings
this.canCtrlDropCopy = true;   // Enable row copy with Ctrl + Drop
this.canAltClickDelete = true; // Enable row delete with Alt + Click

■How to Use

■Usage Example

You can drag and drop the icon on each row to move rows within the table.
Holding the CTRL key while dragging will copy the row instead of moving it.
Holding the ALT key and clicking the icon will delete the row.
(You cannot delete all rows. The last remaining row cannot be removed.)

Column Title1 Column Title2
Cell1-1 Cell1-2
Cell2-1 Cell2-2
Cell3-1 Cell3-2
Cell4-1 Cell4-2