I would like to know if there is a way in jQuery to exlucde a group of elements from a previously selected collection of items. I know I can use “:not” to add exclussion rules when referencing a group of items, but that is not the same question, since I want to know if it is possible to substract a group of elements from a different group of elements already referenced.
¿why is that? because imagine the first group is created according to a set of dynamic rules and some elements could have been added or removed, and when I want to substract the second set of elements from the first group, I dont really know which elements are in the first group. That is, there is no such rule that can be applied using selectors to obtain what I am looking for.
The idea is something like this:
var a = $("selection rules");
var b = $("selection rules2");
//elements from both groups could be removed or new ones added dinamically
var c = b.substract(a);
Use the
notmethod:Here’s the fiddle: http://jsfiddle.net/qfBuj/