内容可编辑,在文本末尾设置插入符号(跨浏览器)输出铬:<div id="content" contenteditable="true" style="border:1px solid #000;width:500px;height:40px;">
hey <div>what's up?</div><div><button id="insert_caret"></button>我相信法夫它看起来会是这样的:hey<br />what's up?和在伊:hey<p>what's up?</p>不幸的是,没有很好的方法使每个浏览器都插入一个<br />而不是一个div或者p标签,或者至少我在网上找不到任何东西。不管怎样,我现在想做的是,当我击中扣子,我希望将插入符号设置在文本的末尾,因此应该如下所示:hey
what's up?|任何方法都可以做到这一点全浏览器?例子:$(document).ready(function(){
$('#insert_caret').click(function()
{
var ele = $('#content');
var length = ele.html().length;
ele.focus();
//set caret -> end pos
}
}
添加回答
举报
0/150
提交
取消