问题描述
我有一个div,其属性为contenteditable="true"
,该div的结构如下:
<div contenteditable="true">
this is the first thing i type
<div>this is the second line i type</div>
<div>this is the third line i type</div>
</div>
当我按Enter换行时,contenteditable内的那些div是由浏览器自动生成的。
我注意到我可以通过设置window.getSelection().setPosition(editableElement.childNodes[LineNumber],0);
我还想要一种方法来更改光标所在的列,但是我找不到方法。我确实注意到,如果我使用向左/向右箭头键手动更改光标列,则会更改window.getSelection()。anchorOffset,但该属性为只读。
如何更改内容可编辑div中光标的水平位置?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)