On 24 jan, 21:15, "Mike L." <[EMAIL PROTECTED]> wrote:
> I've just started using prototype and its been ages since I wrote
> javascript, and I am a little confused by the syntax.
>
> From the online doc I understand that, for example, I can get the
> value of the style 'visibility' like this:
>
>        <div id="someDiv"></div>
>
>         var yy = $('someDiv').getStyle( 'visibility' );
>
> Based on another post I tried:
>
>         var yy = $($('someDiv')).getStyle( 'visibility' );
>

What are you trying to accomplish using this? the dollar function... $
() ... is just shorthand for document.getElementById() and extending
the element with all the prototype methods while you're at it. So what
you're trying to do there is something like this:

  var yy =
document.getElementById(document.getElementById('someDiv')).getStyle('visibility');

Now that doesn't really make sense, does it?
What you probably saw was the $$() function... that function takes a
css-selector as parameter and finds elements with that:

var yy = $$('div#someDiv');

In your case it doesn't really make sense to use the $$ function as
that returns a collection of elements, not just one.

If you do expect to get multiple results you can do something like
this:

$$('div.someClass').invoke('getStyle', 'visibility');

Oh.... and if you're just trying to get the visibility to do something
if it is visible/invisible you might want to look at the method
Element.visible(). This returns true or false and checks not only for
visibility, but also for opacity and display.

> but that didnt work either.  (These give me "... is not a function"
> errors in Firebug.  What does work is:
>
>         var yy = Element.getStyle( $('fade'), 'visibility' );
>
> which I got by reading the code.  That's fine, but I would sure prefer
> the shorthand method especially as what I am beginning will be fairly
> complex.  I am using both Firefox 2.whateverislatest and IE6, by the
> way.
>
> Could someone offer me a quick clue and perhaps point me to some good
> reading to get back up to speed?
>
> Thanks in advance,
>
> Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to