2012-05-30 223 views
0

我想创建一个链接到jQuery选项卡上的锚点,如果你知道我的意思。我有一个页面,我已经锚定了两个标签,#idTab1和#idTab2。我由Sean卡彻波尔,在这里使用jQuery的idTabs ... http://www.sunsean.com/idTabs/链接到另一个页面上的锚点jQuery标签

这是我的代码的嘲笑版本...

<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> 

上面的联系实际工作,并在页面打开,但法律#idTab2链接到第一个选项卡来代替。我会很感激你的任何提示或帮助。

干杯。

回答

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> 
为自己的链接脚本
相关问题