jQuery & jQueryUI Base

by andrewwhitaker

HTML

<link rel="stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.7/themes/black-tie/jquery-ui.css">
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js"></script>
<div id="draggable"></div>

CSS

#draggable { width: 100px; height: 100px; background-color:yellow; }

JavaScript

$("#draggable").draggable({
    drag: function() { 
        if ($(this).hasClass("cancel")) {
            return false;
        }
    }
});

setTimeout(function() {
    $("#draggable").addClass("cancel");
}, 5000);