Yea, seeing how the parse does have to construct your list based on
classes, it will probably be faster to give it a scope limiter as
mentioned (like all .toto in "container"). The fastest possible way to
build the list would be, I think, to make all of your toto divs live
inside one container, then just grab them like such:

$('#toto_contaner').children();

Also, the reason I was using the ref="n" method to set up the list was
for a guaranteed "ref 1 will be toto[1] every time" bit, whereas if
the list of toto elements changed it's position on page, there's no
guarantee the elements would be the same. It's basically the
difference between writing a mysql query that is explicit with column
definitions, and one with implicit definitions.

On Jan 5, 11:26 am, Christof Donat <cdo...@gmx.de> wrote:
> Hi,
>
> > although i couldn't see one or the other or even the other being much
> > faster considering that the selector would have to go through all the
> > elements to see if *any* element on the page either (1) has the
> > specified class or (2) has the specified id
>
> There is document.getElementById() which usually is really fast. If you use
> $('#toto1') uses that. That is why I am not really shure. If you use 50 or
> more times $('#toto'+n).hide() I'd expect the parser and the many function
> calls to take up quite some time, so that the whole construct should not be
> faster than using the class $('.toto').hide().
>
> If all relevant Elements are in the same container, then I'd expect
> $('#container > .toto').hide() to be a good solution. If all the relevant
> Elements are divs and there are more elements in the container, then
> $('#container > div.toto').hide() might give you a bit more speed.
>
> Christof

Reply via email to