Thursday, 8 December 2016

jQuery UI Draggable Div Control

12/08/2016 - By Pranav Singh 0

This article will show you how you can create a jquery Draggable div control using jquery. This article you cam use in asp.net mvc, php and java web applications.

So for this article first we will add the below reference into the header of the page.

<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

After this add the below mention style and jquery code into the header of the page.

<style>
        #draggablediv {
            width: 200px;
            height: 100px;
            padding: 0.5em;
            background-color: green;
        }
    </style>
    <script>
        $(function () {
            $("#draggablediv").draggable();
        });
    </script>

Here in above code I have written the code to drag the div control. The style sheet is used for applying specific style to div control.

Here is the complete code.

<html>
<head>
    <title>jQuery UI Draggable Div Control</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <style>
        #draggablediv {
            width: 200px;
            height: 100px;
            padding: 0.5em;
            background-color: green;
        }
    </style>
    <script>
        $(function () {
            $("#draggablediv").draggable();
        });
    </script>
</head>
<body>
    <div id="draggablediv" class="ui-widget-content">
        <p><b>Move or Drag the div control</b></p>
    </div>
</body>
</html>

Now we done run the application to check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top