用jQuery取消选择选项需要滚动才能真正显示

问题描述

|| 在使用jQuery取消选择选项时,我遇到了一个奇怪的问题。 我现在拥有的代码(用于全部选择):
$select.children().attr(\'selected\',true);
这很好。 对于取消选择,我尝试了各种选项:
$select.children().attr(\'selected\',false);
$select.children().removeAttr(\'selected\');
$select.find(\"option\").attr(\'selected\',false);
$select.find(\"option\").each(function() {
   var $this = $(this);
   $this.removeAttr(\"selected\");
});
等等。并且它们都有相同的问题(在chrome / safari中测试)。运行取消选择代码后,必须实际滚动才能显示未选择的选项。 有想法该怎么解决这个吗? 问候, 莫滕     

解决方法

        尝试添加
$select.val(null);
应该将显示的值还原为选择中的第一个非禁用选项。