我在 HTML 页面上集成了 froala 编辑器。我需要获取我在 div
中写入的数据及其 HTML 属性。
下面是我的代码:
html
<button>
click
</button>
<div id="froala-editor-br">
The editor can use <code>BR</code> tags. When ENTER key is hit, a <code>BR</code> tag is inserted.
</div>
js代码
$('div#froala-editor-br').froalaEditor({
enter: $.FroalaEditor.ENTER_BR
});
$("button").click(function(){
var chk = $('#froala-editor-br').html();
alert(chk);
});
这是工作中的jsfiddle
如果您按下click
按钮,它会获取froala代码,而不是我输入的代码。
最佳答案
只需将您的代码替换为以下脚本即可。
$("button").click(function(){
var chk = $('#froala-editor-br').froalaEditor('html.get');
alert(chk);
});
这是文档链接。
关于javascript - 如何获取 DIV 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49391665/