Created
October 5, 2015 06:00
-
-
Save redknitin/0fb731a0e902f1440eb6 to your computer and use it in GitHub Desktop.
Droppable - Demo 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><html lang="en"> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script> | |
<style> | |
</style> | |
<script> | |
$(document).ready(function() { | |
$('#nit1').draggable({ | |
revert: 'invalid' //Return to orig pos if not accepted by droppable | |
}); | |
$('#nit2').droppable({ | |
//accept: '#nit1', //To filter acceptance | |
drop: function(event, ui){ //Does the 'snap' UI thingie | |
ui.draggable.position({of: $(this), my:'left top', at:'left top'}); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="nit1" style="height: 20px; width: 20px; background-color: red;"> </div> | |
<div style="background-color: green; padding: 3px; display: inline-block;"> | |
<div id="nit2" style="height: 20px; width: 20px; background-color: white;"> </div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment