OnChange not firing in IE

后端 未结 7 1246
我在风中等你
我在风中等你 2020-12-04 01:40

I wish to fire a Onchange event for all the changes of Form elements within a DIV

Here\'s the snippet




相关标签:
7条回答
  • 2020-12-04 02:22

    I had the same problem in Edge and fixed it using an EventListener.

    My code looked like this:

    HTML:

    <input type="text" id="my_id" name="my_name" placeholder="my_placeholder" onchange="my_function(this.value.trim())" autofocus>
    

    Then I changed it to:

    HTML:

    <input type="text" id="my_id" name="my_name" placeholder="my_placeholder" autofocus>
    

    JS:

    document.getElementById("my_id").addEventListener("change", function() {
        my_function(this.value.trim())
    });
    
    0 讨论(0)
提交回复
热议问题