如何获取WMD编辑器的值?

发布于 2024-07-15 03:21:44 字数 363 浏览 6 评论 0原文

我正在尝试使用 WMD 编辑器 (http://wmd-editor.com/)地点。 我有一个非常简单的问题。 当我准备好将文本提交到服务器时; 如何获得编辑器的输出?

像这样的东西只返回“用户在文本区域中输入的实际文本”

    var jtext = document.getElementById('myTextarea').value;

我想获得编辑器的“输出”; 但我不知道如何做到这一点:(

通过输出;我的意思是“Markdown”或“Html”输出。

I am playing around with using the WMD Editor (http://wmd-editor.com/) in my site. I have a really simple question. When I am ready to submit the text to the server; how do I get the output of the editor?

Something like this only returns the 'actual text that user typed in the textarea'

    var jtext = document.getElementById('myTextarea').value;

I would like to get the 'output' of the editor; but I can't figure out how to do that :(

By output; I mean the 'Markdown' or 'Html' output.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲歌长辞 2024-07-22 03:21:44

您将需要使用 javascript 来获取预览 div 的内容。 根据 wmd 站点上的演示,相关 div 具有 wmd-preview 类。 不知道为什么它没有被识别。

在 jQuery 中,您可以使用如下内容:

$('#formname').submit(function() {
    $('#hidden_form_element').val($('.wmd-preview').html());
    return true;
});

You will need to use javascript to get the contents of the preview div. Based on the demo on the wmd site, the div in question has the class wmd-preview. Not sure why it's not id'd.

In jQuery, you'd use something like:

$('#formname').submit(function() {
    $('#hidden_form_element').val($('.wmd-preview').html());
    return true;
});
小矜持 2024-07-22 03:21:44

我相信你可以简单地创建一个带有 id="wmd-output" 的文本区域,它应该允许你提交输出代码

I believe you can simply make a textarea with the id="wmd-output", it should allows you to submit the output code

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文