JS Fiddle
Po zamknięciu div-a "draggable" konsola wali błędami, nie wiem jak zatrzymać taki skrypt po usunięciu div-a.
<!doctype html>
<html lang="en">
<head>
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; background-color:#eee; border:1px solid red;cursor:move;}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#draggable" ).draggable();
} );
</script>
</head>
<body>
<div id="draggable" class="ui-widget-content" >
<a href="#" class="zamknij">zamknij</a>
<span class="clock"><span>
</div>
<script>
$( ".zamknij" ).click(function() {
$( "#draggable" ).fadeOut(300, function() { $(this).remove(); });
});
function clock() {
var time = new Date(), hours = time.getHours(), minutes = time.getMinutes(), seconds = time.getSeconds();
document.querySelectorAll('.clock')[0].innerHTML = harold(hours) + ":" + harold(minutes) + ":" + harold(seconds);
function harold(standIn) {
if (standIn < 10) {
standIn = '0' + standIn
}
return standIn;
}
}
setInterval(clock, 1000);
</script>
</body>
</html>