Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8: Drag and Drop > Getting into drag

Getting into drag

Let’s start with the absolute minimum required to achieve the wonder that is dragging and dropping. By default, all links, text nodes (or selections of text), and image elements are draggable. This means that you don’t have to do anything to tell the browser that these things can be dragged around the page.

Our simple demo will have a drop zone and a couple of images that you can drag into the drop zone. And when you drop them, the image source will appear in the drop zone (Figure 8.1).

Figure 8.1 All images and links are draggable by default. With a little more code, you can make them droppable too.

image

Since there’s nothing to be done to the draggable images, you just need to hook up the drop zone, which requires the following event handlers:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint