Unable to focus an input using JavaScript in IE11

前端 未结 3 1334
孤独总比滥情好
孤独总比滥情好 2021-01-12 14:41

I\'m unable to get IE11 to focus an input element after it is inserted into the DOM. The element won\'t receive text input after being focused, but its placeholder text is n

3条回答
  •  一整个雨季
    2021-01-12 15:11

    The issue was focusing in IE11 is broken when the css property -ms-user-select: none is applied to the input. So by changing:

    * {
      -ms-user-select: none;
    }
    

    into

    *:not(input) {
      -ms-user-select: none;
    }
    

    I was able to solve the problem. Here is a codepen for reproducing the issue: http://codepen.io/anon/pen/yNrJZz

提交回复
热议问题