-
Jun 9th, 2020, 09:50 PM
#1
Thread Starter
Member
HTML div class="drag"
Hello Everyone,
How to disable drag and drop after 6 drags in HTML using draggable.
-
Jun 16th, 2020, 10:04 AM
#2
Re: HTML div class="drag"
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:
Code:
$(function() {
var count = 0;
$( ".drag" ).draggable({
start: function() {
count++;
},
stop: function(event, ui) {
if (count === 6) {
$(ui.helper[0]).draggable("destroy");
}
}
});
});
Live Demo: Fiddle
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|