javascriptdreamweaverspry

How to set default tab in tabbed panel in dreamweaver using javascript


I'm trying to set the default tab in my tabbed panels. In Dreamweaver I used the following code:

<div id="TabbedPanels1" class="TabbedPanels" style="margin: 0 0 20px;">
 <ul class="TabbedPanelsTabGroup">
 <li class="TabbedPanelsTab" tabindex="0">Tab1</li>
 <li class="TabbedPanelsTab" tabindex="0">Tab2</li>
 </ul>
<div class="TabbedPanelsContentGroup">
  <div class="TabbedPanelsContent" >
   content 1
  </div>
  <div class="TabbedPanelsContent" >
   content 2
  </div>
</div>
</div>

I want tab2 to be default(selected) when displayed, so I used following JavaScript:

var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{defaultTab:1});

but it still shows first tab selected instead of second as I want. Why is this happening? Where was I wrong?


Solution

  • <li class="TabbedPanelsTab" tabindex="0">Tab1</li>
    <li class="TabbedPanelsTab" tabindex="1">Tab2</li>
    

    lets say , you want to show up the second tab

    <script type="text/javascript">
    <!--
    var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{ defaultTab: 1 });
    //-->
    </script>
    

    see the use of defaultTab in the above code