Javascript/drag&drop

解説 ドラッグアンドドロップイベント
sample1
  1. リスト項目A
  2. リスト項目B
  3. リスト項目C
sample1code
function sampleDrag( $event ) {
    $event.dataTransfer.setData( "Text", $event.target.id );
}
function sampleDrop( $event, $this ) {
    $event.preventDefault();
    var $data = $event.dataTransfer.getData( "Text" );
    $this.appendChild( document.getElementById( $data ) );
}
function sampleAllowDrop( $event ) {
    $event.preventDefault();
}
function sampleChangeBackgroundColor( $this, $color ) {
    $this.style.backgroundColor = $color;
}