Jquery 禁用的属性未更改
我有以下标记:Jquery 禁用的属性未更改,jquery,Jquery,我有以下标记: $(文档).ready(函数(){ $('#模板')。在('change',function()上{ var$option=$('option:selected',this);//获取选定选项 var optgroup=$option.closest('optgroup').attr('data-customer-type-id'); $(“#winback”).disabled=(optgroup!=“2”); }) }); 电子邮件模板 opt1 opt2 opt3 取消
$(文档).ready(函数(){
$('#模板')。在('change',function()上{
var$option=$('option:selected',this);//获取选定选项
var optgroup=$option.closest('optgroup').attr('data-customer-type-id');
$(“#winback”).disabled=(optgroup!=“2”);
})
});代码>
电子邮件模板
opt1
opt2
opt3
取消日期
jquery对象上没有显示属性disabled
。你应该改变
$('#winback').disabled = (optgroup != "2");
到
属性已禁用
未在jquery对象上公开。你应该改变
$('#winback').disabled = (optgroup != "2");
到
您需要使用正确设置属性值
你能行
$('#winback').prop("disabled", optgroup != "2");
检查完整代码
$(文档).ready(函数(){
$('#模板')。在('change',function()上{
var$option=$('option:selected',this);//获取选定选项
var optgroup=$option.closest('optgroup').attr('data-customer-type-id');
$('#winback').prop(“已禁用”,optgroup!=“2”);
})
});代码>
电子邮件模板
opt1
opt2
opt3
取消日期
您需要使用
你能行
$('#winback').prop("disabled", optgroup != "2");
检查完整代码
$(文档).ready(函数(){
$('#模板')。在('change',function()上{
var$option=$('option:selected',this);//获取选定选项
var optgroup=$option.closest('optgroup').attr('data-customer-type-id');
$('#winback').prop(“已禁用”,optgroup!=“2”);
})
});代码>
电子邮件模板
opt1
opt2
opt3
取消日期