2015-08-14 62 views

回答

1

簡單的代碼編輯本:

$(document).on("pageinit", function() { 
    $("#select").on("change", function() { 
     var selected = $("option:selected", this).length; 
     if (selected == 3) { 
      $("option:not(:selected)", this).prop("disabled", true); 
      $(this).selectmenu("refresh"); 
     } 
     if (selected < 3) { 
      $("option:disabled", this).prop("disabled", false); 
      $(this).selectmenu("refresh"); 
     } 
    }); 
}); 

我們減少if (selected == 3) {到3

工作JSfiddle Link

+0

非常感謝 我使用的菜單都是這個:http://demos.jquerymobile.com/1.4.5/selectmenu-custom/ 我在哪裏放代碼沒有工作,因爲頁面菜單出現在彈出 – rcweb

+0

很高興我可以幫助,將不勝感激,如果你標記答案複選標記:) –

+0

此代碼與版本jquery.mobile-1.4.0工作,我試過但沒有與我合作。 我想在此版本上工作,因爲導航欄圖標不適用於此版本。 – rcweb