2012-05-30 219 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> 
爲自己的鏈接腳本
相關問題