[jQuery] Array of elem IDs

[jQuery] Array of elem IDs


As I have been learning jQuery I developed a technique where I would
use addClass () and removeClass () to attach information to elements
so they can be easily identified and prossed elsewhere in my script.
For example I have 2 main groups of code, one that performs the
application logic and the other applies effects based on the results
of the logic operations. To pass values between the two I would loop
over the arrays in the logic code and addclass() a string to each
element that matched whatever criteria I was testing for. I would
then use a $selector to grab these elements in the effects code so
that I would know what I needed to apply effects to.
The problem I have now discovered with this is that the addClass /
removeClass mechanism is rather slow just for passing variables around
so I am reimplementing the code to use an internal datastructure
(probably either an array or a basic object) to store the results of
the logic operations.
In my effects code I would do things like $('.allElems').filter
('.animate')) or $('.allElems').not ('.animate')) to grab the elements
to which effects should be applied or which should be ignored and so
on. I need to find a way of doing this with a data structure
instead. Each element will have a unique ID associated with it in the
DOM and I will rewrite my logic functions to generate a list of these
IDs. So, if I had an Array or an Object with a list of element IDs in
it, can I use that list to filter out elements with the jQuery filter
() and not () functions?