Jquery - Jquery Wysiwyg将html作为字符串返回 [英] Jquery - Jquery Wysiwyg return html as a string

查看:49
本文介绍了Jquery - Jquery Wysiwyg将html作为字符串返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jquery Wysiwyg编辑器,我正在尝试捕获组成内容区域的html以存储在数据库中。反正有没有得到一个元素的HTML并将其保存为字符串?我的代码看起来像是

I am using the Jquery Wysiwyg editor and I am trying to capture the html that makes up the content area to store in a DB. Is there anyway to get html of a element and save it as a string? My code looks like tihs

<iframe id="wysiwyg_IFrame">
     <html>
        <head></head>
        <body>
           <ul>
              <li>This is a test</li>
           </ul>
        </body>
     </html>
</iframe>

我想要一个以< html>开头的字符串....< / html> 或只是身体< body> ...< / body> 有没有人知道这是否有可能吗?谢谢

I would either like to get a string that starts with <html>....</html> or just the body <body>...</body> does anyone know if this is possible? Thanks

推荐答案

我找到了答案,这是在Jquery Wysiwyg的可怕文档中。它实际上甚至没有在wiki的一部分文档中。要获取内容,您只需要使用文本区域divs名称和.va(),所以对我来说它是

I figured out the answer and it was within the horrible documentation of the Jquery Wysiwyg. It actually wasnt even in the documentation it was in part of the wiki. To get the contents you just need to use the text areas divs name and the .va() so for me it was

 $('#wysiwyg').val();

如果你想设置我想要的内容,例如。从页面中获取内容并在页面加载时将其放在jquery wysiwyg的文本区域中,您需要使用setContent方法,它看起来像这样

If you want to set the contents like I am trying to d, ex. grab something from the DB and place it in the text area of the jquery wysiwyg when a page loads, you need to use the setContent method and it would look like this

 var content = 'place me in the text area';
 $('#wysiwyg').wysiwyg('setContent', content);

感谢所有答案,是的.html()似乎适用于所有其他情况,但不会使用jquery wysiwyg。

Thanks for all the answers and yes .html() seems to work in all other instances but will not work with the jquery wysiwyg.

这篇关于Jquery - Jquery Wysiwyg将html作为字符串返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆