oninput 中文输入
2024-10-20 13:47:49
使用 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 事件里面也加入输入完成后需要进行的下一步操作。
最新文章
- .NET Core采用的全新配置系统[1]: 读取配置数据
- JavaScript高级程序设计学习笔记--事件
- python语句
- Ubuntu .deb包安装方法
- LayoutInflater的使用
- HDOJ 4497 GCD and LCM
- 用Dictionary替换switch case
- SQLServer Note
- Linux后门入侵检测
- HTML页面背景音乐控制
- windows批处理中的%0 %1 %2 %3
- mysql统计一张表中条目个数的方法
- http 2.0
- 关于ODI agent的配置部署
- MySQL Index Merge Optimization
- STM32CubeMX+Keil裸机代码风格(1)
- Linux下main函数启动过程【程序员自我修养笔记】【自用】
- [已解决]An unhandled exception occurred while processing the request.
- SimpleDateFormat 格式化参数说明
- python测试开发django-33.admin后台一对一关系OneToOneField
热门文章
- Angular——自定义过滤器
- The user specified as a definer ('root'@'%') does not exist 解决方法
- 数据库–Cobar分布式数据库集群MySQL中间件
- Knockout 实例
- POJ_3278_Catch That Cow
- .net core Elasticsearch 查询更新
- jmeter元件的作用域和顺序
- Luogu P3797 妖梦斩木棒
- PM2 &; chmod +x
- [luoguP2983] [USACO10FEB]购买巧克力Chocolate Buying(贪心)