You know I'm trying this, just because it is more familiar that the
double dollar sign, but nothing is happening. At least with "this" in
front, I get errors. :-)
On Dec 24, 7:01 am, RobG <[EMAIL PROTECTED]> wrote:
> On Dec 23, 4:26 am, chris at zeus <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm working with stickman's accordion script. and it works great, but
> > I'm trying to add some additional class names my list within the
> > accordion.
>
> > For example:
>
> > <div id="vertical_container">
> > <h2 class="accordion_toggle">First Name</h2>
> > <h2 class="accordion_toggle">Second Name</h2>
> > <h2 class="accordion_toggle">Third Name</h2>
> > </div>
>
> > I'd like it to be this:
>
> > <div id="vertical_container">
> > <h2 class="accordion_toggle name1">First Name</h2>
> > <h2 class="accordion_toggle name2">Second Name</h2>
> > <h2 class="accordion_toggle name3">Third Name</h2>
> > </div>
>
> > I cold set this manually to include an individual class for each one,
> > but I would rather have this done in Javascript.
>
> > function Names() {
> > var mylist = document.getElementById('vertical_container');
> > var h2 = mylist.getElementsByTagName('h2');
>
> > for (var i = 0; i < h2.length; i++) {
> > this.h2.addClassName = 'name' + i;
>
> Drop "this" (which is completely irrelevant here):
>
> h2.addClassName = 'name' + i;
>
> It is hugely faster than using a class selector and each, even if it
> takes a few more lines of code (which you've already written).
>
> --
> Rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---