如何使用jQuery将下拉列表设为只读?
问题描述:
我正在使用以下语句将其设置为只读,但无法正常工作.
I am using the following statement to make it readonly but it is not working.
$('#cf_1268591').attr("readonly", "readonly");
我不想将其禁用,我想将其设置为只读.
I don't want make it disabled, I want to make it readonly.
答
$('#cf_1268591').attr("disabled", true);
下拉列表始终是只读的.您可以做的就是将其禁用
drop down is always read only . what you can do is make it disabled
如果您使用表单,则禁用字段不会提交,因此请使用隐藏字段来存储禁用下拉列表值
if you work with a form , the disabled fields does not submit , so use a hidden field to store disabled dropdown value