Reputation: 480
I have a main div, with sub divs inside:
<div id="selectable">
<div class="item text"></div>
<div class="item image"></div>
<div class="item text"></div>
</div>
When I add the jQuery of:
$('#selectable').selectable();
All of the divs inside are thus selectable.
Is there a way to remove the selectable class on the div that has a class with 'image'?
Thanks
Upvotes: 0
Views: 301
Reputation: 4524
If you want custom selection that is your syntax streight from the UI api
$( "#selectable" ).selectable({ filter: 'div:not(.image)' });
Check it out: http://jsfiddle.net/bBBER/8/
You can be even more spesific
$( "#selectable" ).selectable({ filter: 'div.item:not(.image)' });
Upvotes: 2
Reputation: 24406
Use :not
selector to exclude elements with image
class
$('#selectable').children("div:not(.image)").selectable();
Upvotes: 0
Reputation: 332
You can iterate on each element and then avoid those with class image. Like :
$('#selectable').each(function(div) {
if (!$(this).hasClass('image'))
{
$(this).selectable();
}
});
Upvotes: 0
Reputation: 649
I imagine not as the parent div is selectable and thus everything contained will inherently be selected as they are children of that div. You could simply take some elements out of the selectable div?
Upvotes: -1
Reputation: 53929
Try this:
$( '#selectable > div:not(.image)' ).selectable ();
This selector will select all child div
s of #selectable
that don't have the image
class.
Upvotes: 5