1

在下面的代码中没有任何警报被调用?

<head>
<script src='../../Scripts/jquery/jquery.js' type='text/javascript'></script>
<link rel="stylesheet" href="../../content/jquery-tabs/jquery.tabs.css" type="text/css" media="print, projection, screen">
<script src="../../Scripts/jquery-tabs/jquery.history_remote.pack.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-tabs/jquery.tabs.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $("#tabs").tabs();
    });

    $(document).ready(function() {
        $('#tabs').bind('tabsselect', function(event, ui) {

            // Objects available in the function context:
            alert(ui.tab);     // anchor element of the selected (clicked) tab
            alert(ui.panel);   // element, that contains the selected/clicked tab contents
            alert(ui.index);   // zero-based index of the selected (clicked) tab
        });
    });


</script> 

</head>
<body>

<h2>
    TestTabs</h2>
<div id="tabs">
    <ul>
        <li><a href="#fragment-1"><span>1 Info</span></a></li>
        <li><a href="#fragment-2"><span>2 Info</span></a></li>
        <li><a href="#fragment-3"><span>3 Info</span></a></li>
        <li><a href="#fragment-4"><span>4 Info</span></a></li>
    </ul>
    <div id="fragment-1">
        <h2>TestTabs</h2>
    </div>
    <div id="fragment-2">
        <h2>TestTabs</h2>
    </div>
    <div id="fragment-3">
        <h2>TestTabs</h2>
    </div>
    <div id="fragment-4">
        <h2>TestTabs</h2>
    </div>
</div>

4

2 回答 2

2

它对我有用

确保您使用的是当前版本的 jQuery UI。

你有任何脚本错误吗?

于 2010-01-03T16:45:31.100 回答
2

代码看起来是正确的,这意味着它很可能是以下两种情况之一:

  1. 页面上的另一个 JS 错误
  2. 您没有正确包含 UI 库 + 选项卡

我的猜测是#2,所以你应该仔细检查它是否正常工作。要踢球,请返回http://jqueryui.com/download页面,单击“取消选择所有组件”,然后单击“选项卡”以仅选择coretabs。然后选择“无主题”然后下载。使用该js文件代替您的tabs.min.js文件,然后查看它是否有效。

最后要检查的是,确保您使用的 jQuery + jQuery UI 版本匹配。对于 jQuery 1.3+,请使用 jQuery UI 1.7.2。对于 jQuery 1.2.6,使用 jQuery UI 1.6

于 2010-01-03T16:53:24.177 回答