onclick links in content to open in last tab

I have a changing set of links in the content div of TabA. In each of those links there is an onclick to add content to a div in TabB and the active tab is changed to TabB.

This works well when I have one link, (actually it works for many links but only the first time, clicking subsequent links loads the content but we do not switch to TabB.

How would I alter this to use the class of the link instead? Or is there a better way altogether?

<ul class="subsection_tabs" id="news_tabs">
    <li><a href="#list">TabA</a></li>
    <li><a href="#read">TabB</a></li>
</ul>
<div id="list">
    <h3>List View</h3>
    <a href="" id="news_tabs_last" onclick="ajax request into div read_news">Link One</a>
</div>
<div id="read">
    <h3>List View</h3>
    <div id="read_news">
        News inserted here
    </div>
</div>
      $('news_tabs_last').observe('click',function(event){
            this.last();
            Event.stop(event);
        }.bindAsEventListener(news_tabs));

Posted December 11th, 2007 at 5:11am by stevie

Login or Register to Post