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

but i'm no DOM expert, just seems to make sense  :-/




On Jan 5, 10:50 am, Christof Donat <cdo...@gmx.de> wrote:
> 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');
> toto[1].hide(); toto[2].hide();
>
> That should be the same.
>
> Appart from that I think, that Jean Babtiste wanted to hide all elements at
> the same time. I'd expect his first ( $('.toto').hide() ) version to be
> usually faster, but I'm not shure about that.
>
> Christof

Reply via email to