JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://threedubmedia.googlecode.com/files/jquery.event.drag-1.5.min.js"></script>
<div id="demo2_box" class="box handle">#demo2_box</div>

CSS

.box {
    position: absolute;
    height: 98px;
    width: 98px;
    background: #CCF;
    border: 1px solid #AAD;
    text-align: center;
    font-size: 10px;
}
.handle {
    cursor: move;
}

JavaScript

$('#demo2_box').bind('drag', function(event) {
    $(this).css(event.shiftKey ? {
        top: event.offsetY
    } : {
        left: event.offsetX
    });
});