如何禁用select optgroup(groupbox)?我想禁用选择组复选框。
http://wenzhixin.net.cn/p/multiple-select/docs/
<form action="show.php" method="post">
<select name="test[]" multiple="multiple" id="duo">
<optgroup label="UAE">
<option value="18">Abu Dhabi</option>
<option value="19">Dubai</option>
</optgroup>
<optgroup label="UK">
<option value="22">Birmingham</option>
<option value="94">Brighton</option>
<option value="24">Leeds</option>
<option value="99">Liverpool</option>
<option value="21">London</option>
<option value="85">Luton</option>
<option value="23">Manchester</option>
</optgroup>
</select>
<input type="submit" name="submit" value="submit">
</form>
@import url('http://wenzhixin.net.cn/p/multiple-select/multiple-select.css');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://wenzhixin.net.cn/p/multiple-select/jquery.multiple.select.js"></script>
<script>
$("#duo").multipleSelect({
placeholder: "Here is the placeholder",
width: 200,
selectAll: false,
filter: true,
});
</script>
答案 0 :(得分:1)
标记optgroup
接受属性disabled
。
<select name="test[]" multiple="multiple" id="duo">
<optgroup label="UAE" disabled>
<option value="18">Abu Dhabi</option>
<option value="19">Dubai</option>
</optgroup>
</select>
<强>参考强>
答案 1 :(得分:1)
您应该将disable
道具添加到optgroup
。尝试这样的事情:
$('[label=UAE]').prop('disabled', 'disabled')
在HTML标记中,它必须是:
<select name="test[]" multiple="multiple" id="duo">
<optgroup label="UAE" disabled>
<option value="18">Abu Dhabi</option>
<option value="19">Dubai</option>
</optgroup>
<optgroup label="UK">
<option value="22">Birmingham</option>
<option value="94">Brighton</option>
</optgroup>
</select>
<强> DEMO 强>