4

Basically adding some slider features, and would like to throw the slider under the error CSS class to highlight under certain conditions.

I am programming tooltips to slide along above the handles, and when the error style is added, i want to throw it across all elements, except these handles. The handles are encapsulated in their own <div class="tooltip"> tags, however, when I call the selector to call var div = $(this).find('div:not([class=.tooltip])');, the child elements of this encapsulating div class have their styles updated when i subsequently call div.addClass("ui-state-error ");

TL;DR: Is there any way to call the not() selector such that an element, and all its children, are excluded. I know that explicitly listing the child elements is a quick dirty workaround, but is there anything in the JQuery library to accommodate this?

Note that I am purposely avoiding ID tags as this control will eventually make it into an ASP User Control, and I want to avoid conflicting ID tags later on down the line.

Daniel Park
  • 3,903
  • 4
  • 23
  • 38

1 Answers1

11

Try this :

$(this).find('div:not(.tooltip, .tooltip *)');
Karl-André Gagnon
  • 33,662
  • 5
  • 50
  • 75
  • 1
    This worked. Thanks. I didn't realise the selectors could take on some regex-like properties. Checked [this](http://stackoverflow.com/questions/190253/jquery-selector-regular-expressions) out, and the selector seems more versatile than I first thought. One thing I remember reading, however, is encapsulating things in attribute tags is a good practice. A little bit of reading, and I came up with the alternative `div:not([class^=tooltip])` – Daniel Park Aug 30 '13 at 04:23
  • I am not sure about encapsulating in an attribute tag. See by yourself, class selector is faster : http://jsperf.com/attr-vs-class32 – Karl-André Gagnon Aug 30 '13 at 04:29