[英]How to disable opening of dropdown in select box in jQuery Mobile
我正在使用Jquery Mobile顯示選擇框的下拉列表。
<select id="category_type" multiple="multiple" class="category" tabindex="-1" placeholder="Category">
<option></option>
.
.
</select>
在某些情況下,我需要在單擊時限制打開選擇框的下拉列表。
我嘗試過
jQuery("#category_type").bind( "change", function(e) {
jQuery.mobile.selectmenu.prototype.options.hidePlaceholderMenuItems = false;
e.preventDefault();
});
但沒有效果。 怎么可能? 提前致謝
注意 :這是有效的演示
HTML部分:
<div data-role="fieldcontain">
<button id="disable_select">Disable</button>
<select name="select-choice-1" id="select-choice-1">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
JS部分:
$("#disable_select").click(function() {
$("#select-choice-1").attr("disabled","disabled");
});
現在,我添加了一個按鈕來禁用單擊該按鈕時的下拉菜單,您可以添加條件以禁用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.