© Mark J. Collins 2017

Mark J.  Collins, Pro HTML5 with CSS, JavaScript, and Multimedia, 10.1007/978-1-4842-2463-2_28

Drag and Drop Source Code

Mark J. Collins

(1)Chesterfield, Virginia, USA

Listing B-1 contains the final JavaScript implementation for the Drag and Drop application that was demonstrated in Chapter 24.

Listing B-1. Chapter 24 source code
"use strict";function createBoard() {    var board = document.getElementById("board");    for (var y=0; y < 8; y++) {        var row = document.createElement("div");        row.className = "row";        board.appendChild(row);        for (var x=0; x < 8; x++) {            var square = document.createElement("div");            square.id = x.toFixed() + y.toString();            if ((x + y) % 2) {                square.className ...

Get Pro HTML5 with CSS, JavaScript, and Multimedia: Complete Website Development and Best Practices now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.