使用js定位到可编辑div的末尾
2021-03-31 04:27
标签:tab cti editor get nod onclick gets div select 我看不太懂,额,原文地址: https://www.cnblogs.com/jonie-wong/p/5519822.html 使用js定位到可编辑div的末尾 标签:tab cti editor get nod onclick gets div select 原文地址:https://www.cnblogs.com/woyujiezhen/p/12588808.htmlDOCTYPE html>
html>
head>
meta charset="utf-8">
title>title>
head>
body>
div contenteditable="true" id="guestbook_editor">2div>
button onclick="set_focus()">aabutton>
script>
function set_focus()
{
var el=document.getElementById(‘guestbook_editor‘);
var range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
script>
body>
html>
上一篇:nodejs的使用
下一篇:JSP 04课 (1)