0

如果您知道我的意思,我想创建一个指向 jQuery 选项卡上的锚点的链接。我有一个页面,在该页面上锚定了两个选项卡#idTab1 和#idTab2。我使用 Sean Catchpole 的 jQuery idTabs,在这里... http://www.sunsean.com/idTabs/

这是我拥有的代码的模拟版本......

<div class="usual">
  <ul class="idTabs">
    <li><a name="idTab1" href="#idTab1" class="selected">Terms of Use</a></li>
    <li><a name="idTab2" href="#idTab2">Privacy Policy</a></li>
  </ul>

    <div class="handbook" id="idTab1">
    <p>Some content here...</p>
    </div>

    <div class="handbook" id="idTab2">
    <p>Some content here...</p>
    </div>

</div>

我想要实现的是两个链接,一个用于#idTab1,第二个用于#idTab2。我在下页脚中创建了以下内容...

<div class="subfooter">  
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="100%"><a href="<?php echo url('/content/legal#idTab1');?>">Terms of Use</a> | <a href="<?php echo url('/content/legal#idTab2');?>">Privacy Policy</a><br/>
            <small><?php

            $mtime = explode(' ', microtime());
            $totaltime = $mtime[0] + $mtime[1] - $starttime;
            printf('Page generated in %.3f seconds.', $totaltime);

            ?></small></td>
        </tr>
    </table>
</div>

上面的链接确实有效,页面打开,但 legal#idTab2 链接到第一个选项卡。我很感激你的任何提示或帮助。

干杯。

4

1 回答 1

0

jquery 函数通过首先更改选项卡然后转到锚选项卡来完成此操作。

<script>
function js_tabs_link(tabnum,anchorLink){
    $('#tabs_container_id').tabs('option', 'selected', tabnum);
    //tabnums start from 1 not 0
    window.location = "#"+anchorLink;
}    
</script>

并使用为您的链接调用脚本

<a href='javascript:js_tabs_link("3","about_us")'>about us</a>
于 2012-05-30T14:25:43.117 回答