Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.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 附加时禁用高亮显示的选项_Jquery - Fatal编程技术网

Jquery 附加时禁用高亮显示的选项

Jquery 附加时禁用高亮显示的选项,jquery,Jquery,我将一个禁用的选项添加到一个框中,但我有一个小问题。如果我在中添加选项,其中一个选项将保持高亮显示,这似乎不是什么大问题,但当一个禁用的选项高亮显示,而其他选项显然无法高亮显示时,它看起来并不好 附加选项后,如何删除突出显示?代码如下: var selectedOption = $('select#studentadd'); $('select#studentselect').append(selectedOption.html()).attr('disabled', 'disabled');

我将一个禁用的选项添加到一个框中,但我有一个小问题。如果我在中添加选项,其中一个选项将保持高亮显示,这似乎不是什么大问题,但当一个禁用的选项高亮显示,而其他选项显然无法高亮显示时,它看起来并不好

附加选项后,如何删除突出显示?代码如下:

var selectedOption = $('select#studentadd');
$('select#studentselect').append(selectedOption.html()).attr('disabled', 'disabled');

要清除select中的选定选项,最简单的方法是使用val将select的值设置为空字符串


也许这就是你想要的:

var selectedOption=$'selectstudentadd'; $selectstudentselect.appendselectedOption.html.attrdisabled,disabled; $selectstudentselect选项:selected.removeAttrselected;
工作JSFIDLE is

您好,我尝试了一行代码,但它仍然突出显示在数据被追加时追加的最后一个选项。如果选择了上一个select中的选项,则将val置于末尾
$('select#studentselect').val('').append(selectedOption.html()).attr('disabled', 'disabled');