javascript Summernote 内容带有 html 标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29303187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Summernote content coming with html tags
提问by Shweta M
I am new to summernote text editor. I am trying to get the proper content from the summernote textarea, which infact coming with html tags. I tried
我是 Summernote 文本编辑器的新手。我试图从summernote textarea 中获取正确的内容,它实际上带有html 标签。我试过
<textarea class="summernote" id="summernote" ng-model="blog.content" ></textarea>
in my html page and getting the textarea content with,
在我的 html 页面中获取 textarea 内容,
$("#summernote").code();
it is fetching the content in html tags. I want the content to be displayed without the html tags.
它正在获取 html 标签中的内容。我希望在没有 html 标签的情况下显示内容。
Thank you for the advice.
谢谢你的建议。
采纳答案by Shweta M
After a long time of searching , thought instead of trying that in getting summernote text editor value with plain text, why not try with the angular filter. So searched and got the filter which exactly does what I needed.
经过长时间的搜索,我想与其尝试用纯文本获取summernote 文本编辑器的值,不如尝试使用角度过滤器。所以搜索并得到了完全符合我需要的过滤器。
Here is the link which did my job.
这是完成我工作的链接。
回答by Shweta M
Use val() to get all what entered in textarea or text, So :
使用 val() 获取所有在 textarea 或 text 中输入的内容,所以:
var content = $("#summernote").val()
回答by easylogic
Use $().text() method to get plain text.
使用 $().text() 方法获取纯文本。
$("<div />").html($("#summernote").code()).text();
回答by Mtvw
I had the same problem, "fixed" it by using version 0.6.16 instead of the current stable version 0.7. HTML is rendering fine now without extra js code.
我遇到了同样的问题,通过使用 0.6.16 版而不是当前稳定版 0.7 来“修复”它。HTML 现在可以正常呈现,无需额外的 js 代码。