Select in Opera doesn't close on change event

2019-06-08 11:38发布

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.

3条回答
Bombasti
2楼-- · 2019-06-08 11:45

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楼-- · 2019-06-08 11:51

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

查看更多
Evening l夕情丶
4楼-- · 2019-06-08 11:53

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.

查看更多
登录 后发表回答