<html lang="en"> <head> <title></title> <link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript" src="js/ui/ui.core.js"></script> <script type="text/javascript" src="js/ui/ui.draggable.js"></script> <link type="text/css" href="js/demos.css" rel="stylesheet" /> <script type="text/javascript"> $(function() { $("#drag").draggable(); //define function to toggle draggability function toggle(action) { (action == "destroy") ? $("#drag").draggable(action).removeClass("drag") : $("#drag").draggable(action); } //define click handler for buttons $("button").click(function() { toggle($(this).attr("id")); }); }); </script> </head> <body> <button id="disable">Disable</button> <button id="enable">Enable</button> <button id="destroy">Destroy</button> <div id="drag">asdf</div> </body> </html>