【问题标题】:contenteditable loose focus but writes anywaycontenteditable 松散的焦点,但无论如何都会写
【发布时间】:2014-11-24 18:12:53
【问题描述】:

我正在使用 Foundation alert-boxjoyride。我遇到了一个奇怪的问题; 当我在contenteditable 中写入并打开alert-box 时,当我关闭alert-box(使用x)然后我再次输入(随机字符)即使contenteditable 已松动其focus(我检查了document.activeElement)键入的字母插入到contenteditablekeypress notcontenteditable 上触发,keydown event 在@987654337 上触发@。

这发生在Chrome,在 Firefox 中也可以。

Fiddle

解决问题:当您关注contenteditable 时,然后单击alert-box“x”(contenteditable 将失去焦点),无论如何都会在contenteditable 中键入。

【问题讨论】:

    标签: javascript jquery google-chrome contenteditable


    【解决方案1】:

    解决了这个问题:

    $("#mycontenteditable").on("blur", function(){
       var sel = document.getSelection();
       sel.removeAllRanges();
    })
    

    【讨论】:

      猜你喜欢
      • 2016-11-16
      • 2022-10-26
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 2021-08-28
      • 1970-01-01
      • 2011-04-23
      • 2014-04-26
      相关资源
      最近更新 更多