2013-11-28 72 views
0

這是我的演示鏈接:http://www.bajistech.info/tiltindicators.htmljquery垂直選項卡,跳轉到頁面頂部,如何停止?

我要創建特定的鏈接,每個標籤

function showSection(sectionID) { 
    $('div.section').css('display', 'none'); 
    $('div'+sectionID).css('display', 'block'); 
    } 
    $(document).ready(function(){ 

    if (
     $('ul#verticalNav li a').length && 
     $('div.section').length 
    ) { 
     $('div.section').css('display', 'none'); 
     //$('ul#verticalNav li a').each(function() { 

//不需要每次循環 $( '#UL李verticalNav一')點擊(功能(){

  showSection($(this).attr('href')); 
     }); 
     //}); 
     if(window.location.hash) 
     // if hash found then load the tab from Hash id 
     { 
      showSection(window.location.hash);// to get the div id 
     } 
     else // if no hash found then default first tab is opened 
     { 
      $('ul#verticalNav li:first-child a').click(); 
     } 
    } 
}); 

回答

0

你必須處理HREF時點擊,此代碼添加到您的JS:

$("#verticalNav li a").click(function(event) { event.preventDefault()}); 
+0

喜的朋友,謝謝,但我需要顯示標籤ID也喜歡:tiltindicators.html#TiltWatch-PLUS1。 – user2913707

0

我認爲這將有助於你:

$('ul#verticalNav li a').click(function(){ 
return false; 
}); 
+0

嗨穆罕默德拉希德,謝謝,我需要創建鏈接也像:tiltindicators.html#TiltWatch-Plus1。 – user2913707

相關問題