如何将javascript中的html设置为元素中的特定位置

如何将javascript中的html设置为元素中的特定位置,javascript,jquery,html,Javascript,Jquery,Html,我有一个像这样的div <div contenteditable="true" > Hello this is content editable.... [cursor is blinking here] and more text </div> 你好,这是内容编辑。。。。[此处光标闪烁]和更多文本 如何设置光标闪烁的数据 提前感谢。您可以使用insertHTML命令: document.execCommand("insertHTML", false, "the

我有一个像这样的div

<div contenteditable="true" >
 Hello this is content editable.... [cursor is blinking here] and more text
</div> 

你好,这是内容编辑。。。。[此处光标闪烁]和更多文本
如何设置光标闪烁的数据

提前感谢。

您可以使用
insertHTML
命令:

document.execCommand("insertHTML", false, "the HTML to insert");
现场示例:

$(“div”)。打开(“按键”,函数(e){
如果(e.ctrlKey&&e.which==81){
document.execCommand(“insertHTML”,false,插入的”;
返回false;
}
});
将光标放在下面的相关位置,然后按Ctrl+Q:

你好,这是内容编辑。。。。还有更多的文字
我确信没有人使用Internet Explorer,先生。@mplungjan:Doh!在这里,我想要的是一些无害的东西。OSX上有什么无害的东西吗?