jQuery UI Draggable Axis

ExampleJquery ui draggable axis
Source Code Expand
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.pureexample.com/js/lib/jquery.ui.touch-punch.min.js"></script>

<!-- CSS -->
<style type="text/css">
.drag {
    width: 100px;
    height: 100px;
    border: 1px solid black;
    cursor: pointer;
    border-radius: 10px;
    padding: 5px;
    margin-left: 5px;
    text-algin: center;
    float: left;

<!-- Javascript -->
$(function () {
		axis: "x"

		axis: "y"

<!-- HTML -->
<div id="dragx" class="drag" style="background-color:lightgreen">
	<p>I can only drag left to right </p>
<div id="dragy" class="drag" style="background-color:lightpink;margin-left:300px">
	<p>I can only drag up and down</p>

comments powered by Disqus