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>
|
0 comments:
Please let me know your view