Hello Everyone,
How to disable drag and drop after 6 drags in HTML using draggable.
Printable View
Hello Everyone,
How to disable drag and drop after 6 drags in HTML using draggable.
By draggable, I am assuming you're referring to jQuery UI's draggable API.
You will need to do the following:
- Handle the start event
- Increment the number of times the lement has been dragged by storing the value in variable (or data tag on element)
- Handle the stop event
- Check if the number of times equals 6
- If so, then destroy the draggable binding
Example:
Live Demo: FiddleCode:$(function() {
var count = 0;
$( ".drag" ).draggable({
start: function() {
count++;
},
stop: function(event, ui) {
if (count === 6) {
$(ui.helper[0]).draggable("destroy");
}
}
});
});