2015-12-20 71 views
0

在頁面加載,我只顯示一維數據(缺省數據),現在當上相應的標籤如何顯示與之相關的特定點擊的選項卡如何顯示相關數據點擊李標籤

數據的用戶點擊我的示例代碼

function fetchTopLosersData(tabclicked) { 
    var htmldatafortoploosers = ''; 
    htmldatafortoploosers += '<thead><th class="thheaders">Symbol</th></thead><tbody>'; 
    if (tabclicked === '#1d') { 
     for (var i = 0; i < samplejson1day.length; i++) { 
      var symbol = samplejson1day[i].symbol; 
      htmldatafortoploosers += '<tr> <td>' + symbol + '</td>'; 
     } 
    } else if (tabclicked === '#1w') { 
     for (var i = 0; i < samplejson1week.length; i++) { 
      var symbol = samplejson1week[i].symbol; 
      htmldatafortoploosers += '<tr> <td>' + symbol + '</td>'; 
     } 
    } 

    else if (tabclicked === '#2w') { 
     for (var i = 0; i < samplejson2week.length; i++) { 
      var symbol = samplejson2week[i].symbol; 
      htmldatafortoploosers += '<tr> <td>' + symbol + '</td>'; 
     } 
    } 

    else if (tabclicked === '#3w') { 
     for (var i = 0; i < samplejson3week.length; i++) { 
      var symbol = samplejson3week[i].symbol; 
      htmldatafortoploosers += '<tr> <td>' + symbol + '</td>'; 
     } 
    } 

    $(tabclicked).html(htmldatafortoploosers); 
} 

這是我的小提琴

https://jsfiddle.net/gr1L23us/13/

你能告訴我怎麼顯示與該標籤數據只有

+1

這是你想要什麼? https://jsfiddle.net/mohamedyousef1980/gr1L23us/14/ –

+0

是的,這就是我想要的,非常感謝你... – Pawan

回答

0

先找到所有tab-content-1tab-container-1並隱藏它們,之後顯示點擊菜單上的內容​​點擊下圖。

$("ul.menu li").click(function() { 
    var tabclicked = $(this).find("a").attr("href"); 
    $('.tab-container-1').find('.tab-content-1').hide().html(''); 
    $(tabclicked).show(); 
    fetchTopLosersData(tabclicked); 
}); 

更新小提琴:https://jsfiddle.net/gr1L23us/16/