Remember invoke! :)

$(container).select(".highlighted").invoke("removeClassName", "highlighted");

However, since you'll only have max *one* tab with "highlighted', you
can do just

$(container).down(".highlighted").removeClassName("highlighted");

Other than that, using onclick handlers is ugly, Event.observe to the rescue!

<ul id="tabs">
  <li><a href="#something" class="highlighted">Something</a></li>
  <li><a href="#other_thing">Other Thing</a></li>
  ...
</ul>

$("tabs").select("a").invoke("observe", function(evt) {
  evt.stop();
  $("tabs").down(".highlighted").removeClassName("highlighted");
  this.addClassName("highlighted");
});

Best,
-Nicolas

On Nov 24, 2007 4:56 PM, LexNonScripta <[EMAIL PROTECTED]> wrote:
>
> I think you are trying to do something like this:
> Example:
>
> <div id="holder_of_links">
>     <a href="some_url" onclick="highlight(this,'holder_of_links');
> return false;" class="link_class">Link1</a>
>     <a href="some_url" onclick="highlight(this,'holder_of_links');
> return false;"  class="link_class highlighted">Current link with to
> classes (highlighted)</a>
>     <a href="some_url" onclick="highlight(this,'holder_of_links');
> return false;"  class="link_class">Link3</a>
> </div>
>
> function highlight(link, holder_id){
>     // remove any links with "highlighted"
>     $
> (holder_id).getElementsyClassName('highlighted').each(function(a_link)
> { a_link.removeClassName('highlight'); });
>     // add highlight class to the active link
>     $(link).addClassName('highlighted');
>
> }
>
>
>
> On Nov 24, 7:05 am, PAOEGONVG <[EMAIL PROTECTED]> wrote:
> > Hi, I'm using prototype on a site I'm working on. And I'm trying to
> > figure out how to make it so when someone clicks a link, it makes that
> > on the highlighted tab. Like it removes a specific class from another
> > co   ntainer, and sets it to the clicked on instead?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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