如何使用 javascript 禁用 select_tag
示例:
<button onclick="DisableFields()">Disable</button>
<p class="col-lg-2" id ="test1" >
<%=
select_tag(:customer_service_beneficiary_id, options_for_select(customer_service_beneficiary_col) , :class => "form-control")
%>
</p>
我试过了,但没用:
function DisableFields() {
console.log('Disable');
$("test1").prop('disabled', true);
$("test2").attr('disabled','disabled');
}
最佳答案
试试这个你没有选择div not select
$('select[name="name-of-select"]').attr("disabled","disabled")
关于javascript - Rails - 使用 javascript 禁用 select_tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36543161/