Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
禁用JQuery后无法重新启用select标记_Jquery - Fatal编程技术网

禁用JQuery后无法重新启用select标记

禁用JQuery后无法重新启用select标记,jquery,Jquery,我正在使用change()启用或禁用select标记。我可以禁用标签。但我似乎无法重新启用它 $(函数(){ $('.menu select').change(函数(){ if($(this).val()=='2'){ $('select').not(this).prop('disabled',true); }否则{ $('select').not(this).removeProp('disabled'); $('select option')。removeProp('disabled');

我正在使用
change()
启用或禁用select标记。我可以禁用标签。但我似乎无法重新启用它

$(函数(){
$('.menu select').change(函数(){
if($(this).val()=='2'){
$('select').not(this).prop('disabled',true);
}否则{
$('select').not(this).removeProp('disabled');
$('select option')。removeProp('disabled');
}
});
});

为电影/系列选择分级。。。
G
PG3
PG-13
R
NC-17
电视-14


为电影/系列选择分级。。。 G PG3
请参见
.removeProp()上的:

.removeProp()方法删除由.prop()方法设置的属性

注意:请勿使用此方法删除本机属性,例如选中、禁用或选中。这将完全删除该属性,一旦删除,就不能再次添加到元素中。使用.prop()将这些属性改为false

从DOM元素中删除属性并不会将其状态重置为以前的状态-许多DOM属性方法都是getter/setter方法,因此如果只是删除属性,则不会发生任何事情。您可以在vanilla JS中更清楚地看到这一点:

const select=document.querySelector('select');
select.disabled=true;
删除选择。禁用

为电影/系列选择分级。。。
G
PG3
PG-13
R
NC-17
电视-14

谢谢!对不起,我完全错过了。