使用 input 监听 input 中文输入,会被每次输入的字母打断,下面就解决这个问题

$('input')
.off()
.on('input',function(){
if($(this).prop('comStart')) return;
//输入完成后进行的操作
console.log($(this).val());
})
.on('compositionstart',function(){
$(this).prop('comStart', true);
})
.on('compositionend',function(){
$(this).prop('comStart', false);
//输入完成后进行的操作
console.log($(this).val());
})

compositionstart 是在 input 事件之前触发。

经试验,compositionend 则是在 input 事件之后触发,因此在 compositionend 事件里面也加入输入完成后需要进行的下一步操作。

最新文章

  1. .NET Core采用的全新配置系统[1]: 读取配置数据
  2. JavaScript高级程序设计学习笔记--事件
  3. python语句
  4. Ubuntu .deb包安装方法
  5. LayoutInflater的使用
  6. HDOJ 4497 GCD and LCM
  7. 用Dictionary替换switch case
  8. SQLServer Note
  9. Linux后门入侵检测
  10. HTML页面背景音乐控制
  11. windows批处理中的%0 %1 %2 %3
  12. mysql统计一张表中条目个数的方法
  13. http 2.0
  14. 关于ODI agent的配置部署
  15. MySQL Index Merge Optimization
  16. STM32CubeMX+Keil裸机代码风格(1)
  17. Linux下main函数启动过程【程序员自我修养笔记】【自用】
  18. [已解决]An unhandled exception occurred while processing the request.
  19. SimpleDateFormat 格式化参数说明
  20. python测试开发django-33.admin后台一对一关系OneToOneField

热门文章

  1. Angular——自定义过滤器
  2. The user specified as a definer ('root'@'%') does not exist 解决方法
  3. 数据库–Cobar分布式数据库集群MySQL中间件
  4. Knockout 实例
  5. POJ_3278_Catch That Cow
  6. .net core Elasticsearch 查询更新
  7. jmeter元件的作用域和顺序
  8. Luogu P3797 妖梦斩木棒
  9. PM2 & chmod +x
  10. [luoguP2983] [USACO10FEB]购买巧克力Chocolate Buying(贪心)