IE10 Select box menu shows upside

前端 未结 2 400
渐次进展
渐次进展 2021-01-13 22:54

I was testing my application in IE10 and found a strange behavior for select box. The option selected is highlighted and options above/below are displayed above/below the s

2条回答
  •  我在风中等你
    2021-01-13 23:16

    This is the default behavior of select tag in IE10. That is a pretty good look.

    If you watch carefully, the option is opened based on the position allotted.

    enter image description here

    I have figured a work around using jQuery,

    var position = $("select").on('change', function () {
        position.find('option:selected').prependTo(position);
    });
    

    How it works:

    Whenever you change an option, the selected option will be prepended(in simple moved) to the first position.

    I have create a JSFiddle to show how it works, check it in IE.

    If you're not interested in this feature, then you have look for some plugins.

    My most favorite plugins are:

    1. Chosen
    2. Select2

    Hope you can understand.

提交回复
热议问题