如何在kendo编辑器中提醒所选文本? 我试过下面的代码
<textarea id="editor"></textarea>
<script>
$("#editor").kendoEditor();
var editor = $("#editor").data("kendoEditor");
var html = editor.getSelection();
</script>
但它给了我错误:
无法使用'in'运算符在undefined`
中搜索'getSelection'
然后我的textarea
<textarea id="editor" kendo-editor k-ng-model="html"></textarea>
<script>
var textarea = $("#editor");
textarea.kendoEditor({ value: "Hello, how are you doing !" });
var editor = textarea.data("kendoEditor");
$('#buttonB').click(function () {
alert(textarea);
alert(editor.getSelection());
});
</script>
答案 0 :(得分:0)
使用我在Kendo文档(https://demos.telerik.com/kendo-ui/editor/events)中看到的内容,添加分配给select事件触发的函数的 select 属性:
<script>
var textarea = $("#editor");
textarea.kendoEditor({
value: "Hello, how are you doing !",
select: onSelect
});
var editor = textarea.data("kendoEditor");
function onSelect() {
alert(editor.getSelection());
}
$('#buttonB').click(function () {
alert(textarea);
alert(editor.getSelection());
});
</script>