我正在使用Ckeditor
看法:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="~/Content/ckeditor/ckeditor.js"></script>
<input id="insertPattern" type="button" value="insert pattern" />
@Html.TextArea("editor", new { @class = "ckeditor", id = "aboutme" })
Javascript:
$(function () {
$('input#insertPattern').click(function () {
var txtarea = document.getElementById("aboutme");
var selection = txtarea.getSelection().getStartElement().getOuterHtml();
alert(selection);
}});
如果我单击按钮,则无法警告Ckeditor中Html.TextArea中的鼠标单击选择次数。
错误:
在这部分javascript程式码中
var selection = txtarea.getSelection().getStartElement().getOuterHtml();
我误入歧途,
未定义的typeerror未定义不是函数
我想念哪里?如何获得鼠标单击的选择?
最终,您要在鼠标恰好指向的位置插入文本。这段代码可以做到这一点。
CKEDITOR.instances['aboutme'].insertText("insert some text into this string");
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句