是否可以在一个满足的真正div中设置一个带有contenteditable false的跨度后面的插入符/光标?
示例:
$('#straightHtml').html('<p><span contenteditable="false">test</span></p>')
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='straightHtml' contenteditable="true">
</div>
&#13;
答案 0 :(得分:0)
只需在contenteditable = false span后添加<br>
。
$('#straightHtml').html('<p><span contenteditable="false">test</span><br></p>')
试一试:
$('#straightHtml').html('<p><span contenteditable="false">test</span><br></p>')
&#13;
* {
border: 1px solid black;
}
span {
width: auto;
display: inline-block;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='straightHtml' contenteditable="true">
</div>
&#13;