How to Drag Content using JQuery

This sample demonstrates how to drag content on page using JQuery in web application.

Getting Started

Creating a ASP.NET Application:

  • Open Visual Studio 2010.
  • Go to File => New => Web Site.
  • Select ASP.NET Web Site from the Installed templates
  • Enter the Name and choose the location.
  • Click OK.


Call .js and .css file inside of page head tag.

        <title>JQuery Drag Drop Sample</title>

        #draggable { width: 150px; height: 150px; padding: 0.5em; }
width: 135px;
height: 70px;
            $(function () {
Now run the application to see the result.


Image 1.

You can drag this div anywhere on page just keep pressing mouse left button and move it like image 2.


Image 2.

We are done here, if questions or comments drop me comment in comments section.