From jQuery UI docs cancel option ...
... prevents drag and drop from certain elements.
Let's look at the following example.
HTML:
β<div class="selector">This can be dragged</div>
β<span class="selector">βββββββThis can be dragged</span>
<input type="button" value="This can be dragged" class="selector" />
<button class="selector">This can't be dragged</ββββββββββββββbutton>ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
JavaScript:
$(".selector").draggable({
cancel: "button"
});β
It buttonhas a class here selectorand should be dragged like other elements with the same class. However, the parameter is cancelset for all button, therefore, all elements buttonwith a class selectorare excluded from the drag list and cannot be dragged.
DEMO: http://jsfiddle.net/uPRaH/
li selector, .
<ul>
<li class="selector">This can be dragged</li>
<li class="selector">This can be dragged</li>
<li class="selector not-this">This can't be dragged</li>
<li class="selector">This can be dragged</li>
<li class="selector">This can be dragged</li>
<li class="selector">This can be dragged</li>
<li class="selector">This can be dragged</li>
</ul>β
not-this . cancel:
$(".selector").draggable({
cancel: ".not-this"
});β
DEMO: http://jsfiddle.net/uPRaH/1/
, cancel .
...
<div class="selector">
Draggable
<div>Draggable</div>
<span>Not draggable</span>
<div>Draggable</div>
Draggable
</div>
... , selector , span:
$(".selector").draggable({
cancel: "span"
});β
DEMO: http://jsfiddle.net/uPRaH/2/