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());
});

  

posted @ 2018-06-17 14:33  Fury_Fox  阅读(215)  评论(0编辑  收藏  举报