如何使选择下拉列表只读和不可更改

How to make select drop down list read only and unchangeable

本文关键字:可更改 只读 下拉列表 何使 选择      更新时间:2023-09-26

这是js提琴的链接

[https://jsfiddle.net/7Lcf533c/1/][1]

我将select下拉选项设置为只读但是当我点击它的时候它显示了下拉选项本来不应该显示的而且它是可变的

你能建议一个解决方案并更新在jsfiddle

你可以这样做:

$("#id_messageKindId option").prop('disabled',true);

use disabled attribute

 <div class="col-sm-8"><select class="form-control" id="id_messageKindId" name="messageKindId" disabled="disabled" required="required" readonly="">
<option value="1">Appointment Reminder</option>
<option value="2">Eyeware or Contact Arrival</option>
<option value="3">Appt Delay / Move Up</option>
<option value="4">Appt Cancellation</option>
<option value="5">Recall</option>
<option value="7">After Appointment</option>
<option value="10" selected="selected">Pre Appointment</option>
<option value="11">Lab Results</option>
<option value="12">Collection Message</option>
<option value="13">Custom Message</option>
</select></div>

fiddle at https://jsfiddle.net/7Lcf533c/5/