gpt4 book ai didi

javascript - 使用清除图标清除 IE10 上的文本输入时触发的事件

转载 作者:IT王子 更新时间:2023-10-29 02:47:01 24 4
gpt4 key购买 nike

在 chrome 上,当用户点击清除按钮时,搜索输入会触发“搜索”事件。

有没有办法在 Internet Explorer 10 的 javascript 中捕获相同的事件?

enter image description here

最佳答案

我最终找到的唯一解决方案:

// There are 2 events fired on input element when clicking on the clear button:
// mousedown and mouseup.
$("input").bind("mouseup", function(e){
var $input = $(this),
oldValue = $input.val();

if (oldValue == "") return;

// When this event is fired after clicking on the clear button
// the value is not cleared yet. We have to wait for it.
setTimeout(function(){
var newValue = $input.val();

if (newValue == ""){
// Gotcha
$input.trigger("cleared");
}
}, 1);
});

关于javascript - 使用清除图标清除 IE10 上的文本输入时触发的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14498396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com