gpt4 book ai didi

javascript - onBlur 事件 nicEditor JQuery 的问题

转载 作者:行者123 更新时间:2023-11-28 05:03:23 25 4
gpt4 key购买 nike

我正在尝试从 nicEdit 复制内容内容更改时的实例:

var myInstance  = new nicEditor({  iconsPath : 'https://cdn.jsdelivr.net/nicedit/0.9r24/nicEditorIcons.gif'}).panelInstance('drag_words_paragraph');
myInstance.addEvent('blur', function() {
var nicInstance = nicEditors.findEditor('drag_words_paragraph');
var drag_words_paragraph11 = nicInstance.getContent();
$("#list_id").html(drag_words_paragraph11);
});

相反,当我单击页面上的任意位置时,我会收到警报。我该如何解决这个问题?

最佳答案

正如前面的答案中所述,请尝试以下代码片段。如果您遇到任何错误,请告诉我。这里仅当文本更改时才会触发警报。

body {
min-height: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/nicedit/0.9r24/nicEdit.js"></script>
<textarea class="form-control" style="width: 300px; height: 100px;" name="drag_words_paragraph" id="drag_words_paragraph">
Enter your text here...
</textarea>
<br/>
<p id="list_id"></p>
<script>
var drag_words_paragraph;

$(function() {
window.drag_words_paragraph = $('#drag_words_paragraph').text();

var myInstance = new nicEditor({
iconsPath: 'https://cdn.jsdelivr.net/nicedit/0.9r24/nicEditorIcons.gif'
}).panelInstance('drag_words_paragraph');
myInstance.addEvent('blur', function() {
debugger;
var text = this.instanceById('drag_words_paragraph').getContent();
if (window.drag_words_paragraph == text) {
$("#list_id").html(text);
return false;
} else {
alert('text changed');
window.drag_words_paragraph = text;
$("#list_id").html(text);
}
});
});
</script>

关于javascript - onBlur 事件 nicEditor JQuery 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41958951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com