如何为初始加载设置默认选项卡

时间:2015-05-12 22:08:10

标签: javascript jquery jquery-tabs

目前this webpage会打开“Freebies& Extras”标签。我希望它打开第一个标签,“联邦与安理会”。我相信,默认情况下,它会打开第一个标签。我试图找到它告诉浏览器在第三个选项卡上打开它但找不到它的位置。

2 个答案:

答案 0 :(得分:1)

我认为这是您正在寻找的代码:

$('div#Panels').tabs({
    active: 2,

active选项告诉标签控件显示哪个标签。

如果您将active值更改为0(或完全删除它),则应显示页面加载时的第一个标签。

由于最初显示的选项卡未触发activtate事件,您可以将代码从activate事件处理程序移动到单独的函数中,然后在{{1}中调用该函数事件处理程序以及页面首次加载时。

activate

答案 1 :(得分:0)

You need to set the active to 0 in the code

<?php
class Foo
{
    public static $my_static = 'foo';
}

$foo = new Foo();
print $foo::$my_static . "\n";     // Accessable throught the class
print $foo->my_static . "\n";      // Undefined "Property" my_static     
?>

UPDATE

When you click the tab 0, then the page runs this code:

$(document).ready(function() {
    $('div#Panels').tabs({
    active: 2,
    collapsible: false,
    activate: function(event, ui) {...

Since you are not clicking this tab to start, this code is not running when the tab opens. You need to run the code by yourself. I suggest create a function and call it right after defining the tabs.

The full script would be (maybe something is misplaced, because I haven't run it):

$('#carousel').flexslider({
   animation: "slide",
   controlNav: false,
   animationLoop: true,
   slideshow: false,
   itemWidth: 80,
   itemMargin: 5,
   asNavFor: '#slider'
});

$('#slider').flexslider({
   animation: "slide",
   controlNav: false,
   animationLoop: true,
   slideshow: false,
   sync: "#carousel"
});

//-----------------
$(window).resize();
//-----------------