在 IE10 中,文本框中会出现一个小 X 图标以清除输入文本.如何将事件附加到该操作(=单击该 X 并清除输入)?
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)?
这似乎没有确切的事件(onchange 不合适).但是,您可以使用 oninput 并检查 input 的值是否为空:
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);
如果用户使用 BACKSPACE 或 DELETE 清除 input 或将内容剪切到剪贴板,也会触发此事件.oninput 至少在 Chrome、FF、IE10 和 Opera 中有效.
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.
这篇关于附加事件以清除 IE10 文本框中的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
检查一个多边形点是否在传单中的另一个内部Check if a polygon point is inside another in leaflet(检查一个多边形点是否在传单中的另一个内部)
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
触发点击传单标记Trigger click on leaflet marker(触发点击传单标记)
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
将 Leaflet 图层控件添加到侧边栏Adding Leaflet layer control to sidebar(将 Leaflet 图层控件添加到侧边栏)
Leaflet - 在弹出窗口中获取标记的纬度和经度Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在弹出窗口中获取标记的纬度和经度)