有没有一种方法可以使用jQuery。在可满足的文本位置上贴上?
就像标题所述的那样,是否有一种使用jQuery的方法。在可满足的Div,选定的文本位置上应用?我可以在该位置插入HTML的可满足插件。但是我需要jQuery .Append函数。
干杯!
var ffclickcount = 0;
$('#fff').click(function(e) {
ffclickcount = ffclickcount + 1;
var newfff = '<br/><form> <textarea id="ItemNEW' + ffclickcount + '"></textarea> </form><br/>';
$("#Ntext").append(newfff);
});
// IN MY OWN CODE I HAVE THIS ALSO INSIDE THE VAR NEWFFF BUT THAT GIVES A ERROR ON SO SNIPPET //
// <script> var editor = CodeMirror.fromTextArea(document.getElementById("ItemNEW'+ffclickcount+'"), { mode: "text/html", theme: "eclipse", lineWrapping: true, styleActiveLine: true, matchBrackets: true, readOnly: false }); var charWidth = editor.defaultCharWidth(), basePadding = 4; editor.on("renderLine", function(cm, line, elt) { var off = CodeMirror.countColumn(line.text, null, cm.getOption("tabSize")) * charWidth; elt.style.textIndent = "-" + off + "px"; elt.style.paddingLeft = (basePadding + off) + "px"; }); editor.refresh(); </script>
.SWItextar {
width:100%;
max-width:100%;
height:50vh;
min-height:50vh;
margin-top:1vh;
margin-bottom:1vh;
border-top:1px solid #eee;
border-bottom:1px solid #eee;
resize: vertical;
overflow-x: auto;
outline:none;
cursor: text;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<span id="fff">click insert form</span>
<div name="text" id="Ntext" class="SWItextar" contenteditable="true" autofocus></div>
Like the title say's, Is there a way to use jQuery .append on contenteditable div, selected text position? I can find a lot for the contenteditable insert html at that position. But I need the jQuery .append function.
Cheers!
var ffclickcount = 0;
$('#fff').click(function(e) {
ffclickcount = ffclickcount + 1;
var newfff = '<br/><form> <textarea id="ItemNEW' + ffclickcount + '"></textarea> </form><br/>';
$("#Ntext").append(newfff);
});
// IN MY OWN CODE I HAVE THIS ALSO INSIDE THE VAR NEWFFF BUT THAT GIVES A ERROR ON SO SNIPPET //
// <script> var editor = CodeMirror.fromTextArea(document.getElementById("ItemNEW'+ffclickcount+'"), { mode: "text/html", theme: "eclipse", lineWrapping: true, styleActiveLine: true, matchBrackets: true, readOnly: false }); var charWidth = editor.defaultCharWidth(), basePadding = 4; editor.on("renderLine", function(cm, line, elt) { var off = CodeMirror.countColumn(line.text, null, cm.getOption("tabSize")) * charWidth; elt.style.textIndent = "-" + off + "px"; elt.style.paddingLeft = (basePadding + off) + "px"; }); editor.refresh(); </script>
.SWItextar {
width:100%;
max-width:100%;
height:50vh;
min-height:50vh;
margin-top:1vh;
margin-bottom:1vh;
border-top:1px solid #eee;
border-bottom:1px solid #eee;
resize: vertical;
overflow-x: auto;
outline:none;
cursor: text;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<span id="fff">click insert form</span>
<div name="text" id="Ntext" class="SWItextar" contenteditable="true" autofocus></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论