美文网首页
js 中文输入不打断

js 中文输入不打断

作者: loewe0202 | 来源:发表于2019-04-15 09:27 被阅读0次
  // 输入过程
  $("input[name=search]").on("input propertychange", function () {
    if ($(this).prop('comStart')) return; // 中文输入过程中不截断
    searchFn(this);
  }).on('compositionstart', function () {
    // 中文输入开始
    $(this).prop('comStart', true);
  }).on('compositionend', function () {
    // 中文输入结束
    $(this).prop('comStart', false);
    searchFn(this);
  });
  // 处理输入结果事件
  let searchFn = (that) => {
    // todo
  };

相关文章

网友评论

      本文标题:js 中文输入不打断

      本文链接:https://www.haomeiwen.com/subject/giyywqtx.html