JQuery Tutorials

Drag a layer

Make a link to the JQuery file and the JQuery User Interface

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

Create a CSS style for your layer

<style type="text/css">
#myLayer {
width: 400px;
height: 200px;
border: 1px solid #ccc;
background: #f0f0f0;
font: 10px Verdana, Geneva, sans-serif;
}
.myLayerTitle {
background: #ccc;
padding: 4px 10px;
}
.myLayerContent {
padding: 10px;
}
</style>

Create a function to drag the layer

<script>
$(document).ready(function(){
$("#myLayer").draggable();
$("#myLayer").draggable({cursor:'move'});
});
</script>

Add a layer on the page

<div id="myLayer">
<div class="myLayerTitle">Drag</div>
<div class="myLayerContent">This layer is draggable</div>
</div>

Demonstration

Drag
This layer is draggable
JQuery Tutorials
Other Tutorials