jQuery判断输入法和非输入法输入
需求背景:
页面需要输入完成后自动查询。
解决方案:
$('input').on('input', function() {
if ($(this).prop('comStart')) return;
console.log('当前输入:' + $(this).val());
}).on('compositionstart', function(){
$(this).prop('comStart', true);
console.log('中文输入:开始->' + $(this).val());
}).on('compositionend', function(){
$(this).prop('comStart', false);
console.log('中文输入:结束->' + $(this).val());
});
我得不断学习,才会知道这个地方到底要写什么。

浙公网安备 33010602011771号