00 Votes

jQuery UI Draggable: Multiple Cancel-Selectors

Question by Compi | 2014-06-11 at 16:18

I am using the jQuery UI widget "Draggable" to be able to move a DIV-Box on my website. However, on some elements placed on the DIV, the movement should not be possible (for example on input fields).

Up to now, I have the following code which is really working very very good (cancel contains the elements, on which it should not be possible to start the move).

   cursor: 'move',
   cancel: '.nodrag'

However, this is only a working, when only providing one selector in "cancel". I would like to add input fields as well as textareas here, too.

Is it possible to use "cancel" with multiple selectors?

0Best Answer0 Votes

You can just separate multiple selectors using a comma:

cancel: '.nodrag, #myid, textarea, input' 

This selector would select all elements having assigned the class "nodrag", the element with the ID "myid" as well as all textareas and input elements.

More information about this, you can find on the jQuery website on to the topic Multiple Selector.
2014-06-11 at 18:43

ReplyPositive Negative

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.