本文介绍了如何在父ContentEditable div中输入内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不保留孩子的类的情况下在contentEditable div的子元素外键入contentEditable div,并且不将contentedable更改为false。
< div class =containercontenteditable =true>
< span class =meatballcontenteditable =true>肉丸< / span>
< / div>
应该是这样的:
< div class =containercontenteditable =true>
< span class =meatballcontenteditable =true>肉丸< / span>意大利面
< / div>
不是这样:
< div class =containercontenteditable =true>
< span class =meatballcontenteditable =true>肉丸意大利面< / span>
< / div>
解决方案
像这样,通过添加一个隐形字符来欺骗浏览器& zwnj;
。我还添加了一个额外的< span>
以避免插入符号视觉错误
How can you type inside a contentEditable div outside of a child contentEditable div without retaining the child's class, and without changing contenteditable to false.
<div class ="container" contenteditable="true">
<span class="meatball" contenteditable="true">meatball</span>
</div>
Should be this:
<div class ="container" contenteditable="true">
<span class="meatball" contenteditable="true">meatball</span> spaghetti
</div>
Not this:
<div class ="container" contenteditable="true">
<span class="meatball" contenteditable="true">meatball spaghetti</span>
</div>
解决方案
Like this, by adding an invisible character to trick the browser ‌
http://jsfiddle.net/bq6jQ/4/ . I also add an extra <span>
to avoid a caret visual bug
这篇关于如何在父ContentEditable div中输入内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!