是否可以知道输入字段中的文本是通过键入还是使用粘贴添加的?
$('document').on("keyup", ".tfs", function(e) {
alert("typed text");
})
$('.tfs').on('paste', function(e) {
alert("paste text!");
});
编辑:
我正在寻找一种不是内联代码解决方案的解决方案,例如 onpaste()
。我需要按照上面的代码使用 bind
(.on
now)来执行此操作。
最佳答案
有些东西可能会有所帮助
$(document).ready(function() {
$("#textA").bind({
copy : function(){
$('span').text('copy behaviour detected!');
},
paste : function(){
$('span').text('paste behaviour detected!');
},
cut : function(){
$('span').text('cut behaviour detected!');
}
});
});
关于javascript - 识别粘贴文本并键入文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30340900/