html 在 IE 11 中单击后数据列表项未更改所选值

html datalist item not getting the selected value changed after a single click in IE 11

我正在使用 HTML Datalist,它在 Chrome 中运行良好。但在 IE 中,它没有按预期工作。

问题:选择任何一个选项后,它在end.Ideally处带有一个'x'标签-link,它应该取选定的值,但它没有取。我们需要点击外面的某个地方然后它就开始了。

期望:需要一个触发onchange值的函数,目前无法顺利实现(因为需要点击外面的某个地方让事件发生)。

这是我的示例代码:

    <html>
    <body>

    <form>
      <input list="browsers" name="browser" onchange="callFunction()">
      <datalist id="browsers">
        <option value="Internet Explorer">
        <option value="Firefox">
        <option value="Chrome">
        <option value="Opera">
        <option value="Safari">
      </datalist>
    </form>
    </body>

<script>
function callFunction(){
alert("onchange got triggered");
}
</script>
    </html>

您目前拥有:

...

</body>

<script>
function callFunction(){
alert("onchange got triggered");
}
</script>
</html>

我不认为这是有效的 HTML,它可能会导致某些网络浏览器出错。尝试将 <script>...</script> 放在 <body>...</body>.

...

<script>
function callFunction(){
alert("onchange got triggered");
}
</script>

</body>
</html>