Select in Opera doesn't close on change event

跟風遠走 提交于 2019-12-08 04:26:28

问题


In Opera (and only in Opera) I have strange behavior of select element. In change event, if I disable this select, it doesn't close (collapse).

    $('select').bind('change', function()
    {
        $(this).attr('disabled', true);
    });

Is it some known issue of opera? So far I haven't found anything.


回答1:


Use a short delay before disabling the select, 10ms should be sufficient




回答2:


Setting disabled attribute did not work for me, but this code works:

$('select').change(function() {  
  $(this).hide();
  var _this = this;
  setTimeout(function() {
    $(_this).show();
  }, 1);
});

Just hide select, and after one millisecond show it.




回答3:


Yes, this is a known bug in Opera (as in the "Opera Software knows about it and is working on a fix, but pretty much nobody else in the world can tell because of Opera's closed bug tracker" meaning of "known"). As far as I remember it may even be fixed for Opera 12 but I haven't double-checked that.

For workarounds, you may want to just leave it since a fix is coming in a future Opera version, using a timeout as suggested earlier should work too.



来源:https://stackoverflow.com/questions/7684991/select-in-opera-doesnt-close-on-change-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!