The reason why it is broken is because you are declaring the drag
function after the HTML is referencing drag
.
You will need to move your JS code up (try placing it in a seperate file, and 'ing it before anything in your
Part 2: The reason why your code fails is because you have not set an ID for the element to be dragged. Set an ID for the element, and it will work: