2013-01-02 50 views
-3

在Accordion jQuery功能中,如何在不使用UI插件的情況下使用左側,右側,頂部和底部動態切換標籤位置?如何使用jQuery Accordian動態地移動標籤位置?

例子:有一個下拉具有四個值這些1.top 2.bottom 3.left和4.right

If i click on top - Tabs should display top to bottom direction 
If i click on bottom - Tabs should display bottom to top direction 
If i click on left - Tabs should display left to right direction 
If i click on left - Tabs should display right to left direction 
+1

您能解釋一下從左到右的方向和從右到左的方向是什麼意思嗎?手風琴是垂直的。 –

+0

假設有4個選項卡,即Tab1,Tab2,Tab3和Tab4,它們從上到下排列,這將是默認情況下,如果我選擇底部,它應該顯示從下到上即tab4到tab1,並且它應該顯示左側從右側tab1到右側tab4,如果我點擊右邊它應該顯示riht左邊從tab4到tba1。 – user1943681

回答

0

你可以試試下面的代碼。請注意,此代碼不完整。您需要添加所有案例...

$("select").change(function() { 
    var str = ""; 
    $("select option:selected").each(function() { 
     str += $(this).text() + " "; 
    }); 

    switch (str) { 
    case 'top': 
     $("#tabs").addClass("ui-tabs-vertical ui-helper-clearfix"); 
     $("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left"); 
     break; 

    case 'bottom': 
     // fix the classes 
     $(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *") 
      .removeClass("ui-corner-all ui-corner-top") 
      .addClass("ui-corner-bottom"); 

     // move the nav to the bottom 
     $(".tabs-bottom .ui-tabs-nav").appendTo(".tabs-bottom"); 
     break; 

    case 'left': 
     // change the required classes 
     break; 

    case 'right': 
     // change the required classes 
     break; 
    } 
}); 
+0

你可以給我提供什麼是這些ui-tabs-vertical和ui-helper-clearfix和類似的類。 – user1943681

+0

這些是jQuery標籤插件使用的類。你可以在[jQuery選項卡文檔](http://jqueryui.com/tabs/#bottom)中找到這些類。檢查頁面中示例的源代碼(jQuery選項卡文檔)。 – Wolf

+0

嗨,在這個例子中,當我從選擇下拉列表中選擇一個值時,選擇的值不是來切換case..its顯示NAN可以ü請給我提供開關盒功能 – user1943681