Hi,
> $('#toto_contaner').children();
That only works, if all .toto elements are direct children of #toto_contaner
and there are no other elements in #toto_contaner.
In case only the second assumption does not hold, I guess
$('#toto_contaner > div.toto').hide() is the fastest solution.
If th
I think Eric Hobo's piece is probably faster for any collection
regardless of size, since it's essentialy just document.getElementById
('toto').childNodes
On Jan 5, 2:02 pm, Will Anderson wrote:
> I think comparing two strings would be faster than deciding whether a
> string begins with another
I think comparing two strings would be faster than deciding whether a
string begins with another string.
Also, doing one selection would almost always be faster than doing 3,
so I'd say that the first piece of code from the OP would be faster.
It should only require one loop through the DOM tree.
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, th
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() w
In any event, using the element's type together with a class selector
will improve performance (otherwise every single element in the
current context is checked for that class):
$('div.toto').hide();
With a single element (or very few) using an id will probably be
faster, but with 50+ elements,
And another way:
$("div[id^='toto']").hide();
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
Hi,
> And try something like:
>
> var toto = [];
> $('.toto').each(function(){
> var elem = $(this);
> toto[elem.attr('ref')] = elem;
> }
>
> Then, to hide the "toto" div with ref="1" or ref="2", just call:
>
> toto[1].hide(); toto[2].hide();
Why not use this:
var toto = $('.toto');
tot
Honestly, it's going to be faster to create a master list of "toto"
elements, and just traverse that list. Implementation of this is
pretty straightforward.
If you alter the HTML to resemble something like this:
And try something like:
var toto = [];
$('.toto').each(function(){
var elem
9 matches
Mail list logo