【问题标题】:Javascript/jQuery : Refocus a contenteditable div that has child elements withinJavascript/jQuery : 重新调整包含子元素的内容可编辑 div
【发布时间】:2011-03-30 09:50:11
【问题描述】:

我的目标: 我正在输入内容可编辑字段中的哈希标签。我希望能够删除它输入的哈希标记,将其附加到另一个容器并将选择重新聚焦在 contenteditable div 上,就好像什么都没发生一样。

我的问题: 只要 contenteditable div 中没有子元素,此方法就可以工作,但如果有子元素,则焦点不会恢复。我想我需要一种先进的方法来聚焦插入符号。到目前为止,这仅在 Chrome 中进行了测试。

我的例子: http://jsbin.com/owoto4/5/edit

帮助不胜感激!

【问题讨论】:

    标签: javascript jquery focus contenteditable setfocus


    【解决方案1】:

    我可能已经通过使用这篇文章中的代码破解了它: contenteditable, set caret at the end of the text (cross-browser)

    现在看我的例子:http://jsbin.com/owoto4/5/edit

    【讨论】:

      猜你喜欢
      • 2020-12-04
      • 2017-09-21
      • 1970-01-01
      • 1970-01-01
      • 2016-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多