在完全可信的真正div

时间:2017-06-08 20:51:04

标签: html position contenteditable caret

是否可以在一个满足的真正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;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

只需在contenteditable = false span后添加<br>

$('#straightHtml').html('<p><span contenteditable="false">test</span><br></p>')

试一试:

&#13;
&#13;
$('#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;
&#13;
&#13;