Attach event to clear icon in IE10 textbox

旧时模样 提交于 2019-11-27 06:45:36

问题


In IE10 a small X icon appears in the textbox to clear the input text. How can an event be attached to that action (=clicking on that X and clearing the input)?


回答1:


It seems there's not an exact event for this (onchange is not suitable). However, you can use oninput and check, if the value of the input is empty:

document.getElementById('input_ID').addEventListener('input', function () {
    if (this.value === '') {
        alert('No value');
    }
}, false);

This event is triggered also, if user clears the input with BACKSPACE or DELETE, or cuts the content to the clipboard. oninput works at least in Chrome, FF, IE10 and Opera.




回答2:


pl refer :Event fired when clearing text input on IE10 with clear icon



来源:https://stackoverflow.com/questions/14700466/attach-event-to-clear-icon-in-ie10-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!