Hi Grant,

The syntax of the code you posted is correct, so I'd look above it --
invalid label suggests that there's something above it that's
incorrect and putting the parser in an odd state.

Going beyond the original question a bit, although the syntax is fine,
the raw NodeList you'll get back from document.getElementsByClassName
won't have the Enumerable methods on it (like each()).  The good news
is that that's what $$[1] is for, so:

document.observe('dom:loaded', function(){
        var blockbody = $$('.blockbody');
        blockbody.each(Element.hide);
});

or alternately:

document.observe('dom:loaded', function(){
        var blockbody = $$('.blockbody');
        blockbody.invoke('hide');
});

Either of which should work once whatever's mucking up the parser
prior to this code is dealt with.  (Although the invoke version would
be a bit slower in this case, if there are a lot of these blockbody
things.)

[1] http://www.prototypejs.org/api/utility/dollar-dollar

HTH,
--
T.J. Crowder
tj / crowder software / com

On Nov 24, 11:57 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello all
>
> I am new to Prototype/Scriptaculous and have been trying to get
> something working on dom:loaded rather than once the page has
> rendered. I have done a reasonable amount of Googling, though the
> things that I have tried have been of no success.
>
> Any help is greatly appreciated!
>
> My code:
>
> // Revision 1
> //Event.observe(document,'dom:loaded', function(){
> //      var blockbody = document.getElementsByClassName('blockbody');
> //      blockbody.each(Element.hide);
> //      alert('hi');
> //});
>
> Event.onReady(function() {
>         var blockbody = document.getElementsByClassName('blockbody');
>         blockbody.each(Element.hide);
>
> });
>
> I tried:
>
> document.observe('dom:loaded', function(){
>         var blockbody = document.getElementsByClassName('blockbody');
>         blockbody.each(Element.hide);
>
> });
>
> To which the Firefox error console returned: 'document.observe':
> invalid label
>
> Thanks!!
>
> Grant
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to