[英]Input event triggered on Internet Explorer when placeholder changed
正如在這個jsfiddle示例中所示,當我更改占位符時,它會觸發輸入事件。 我在IE 11版本上測試過,但我猜舊版本有同樣的問題。 其他瀏覽器的行為不像這樣。 這是IE漏洞嗎? 如果是這樣,IE上的這個問題的解決方法是什么?
這是html標記。
<input type="text" />
<button>Change PlaceHolder</button>
這里是javascript部分。
var i = 0;
$('button').click(function(){
$('input').attr('placeholder','placeholder ' + i++);
});
$('input').bind('input',function(){
alert('input even occur');
});
檢查輸入是否重點應該足夠了
$('input').bind('input',function(){
if($(document.activeElement) != $('input'))
return;
alert('input even occur');
});
當占位符包含重音字符時,這也會“修復”觸發的輸入事件,而不會執行任何操作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.