如何在内容可编辑div中保留空格 [英] How to preserve white spaces in content editable div

查看:907
本文介绍了如何在内容可编辑div中保留空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用内容可编辑div作为字段来获取我的网站中的用户输入。
但是我的问题是,当我得到的div的内容使用jquery所有的白色空间丢失,由用户输入的div?

I am using the content editable div as a field to fetch user inputs in my website. But my problem is that when i get the contents of the div using jquery all the white spaces are lost which are entered by the user in the div ?

感谢

推荐答案

我在这里找到了答案: http://simonewebdesign.it/blog/how-to-make-browser-editor-with-html5-contentitable/

I found the answer here: http://simonewebdesign.it/blog/how-to-make-browser-editor-with-html5-contenteditable/

您的css样式内容可编辑元素应包含以下内容:

Your css style for the content-editable element should contain the following:

.content_editable_element {

.content_editable_element {

    white-space: pre-wrap;       /* css-3 */
    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
    white-space: -pre-wrap;      /* Opera 4-6 */
    white-space: -o-pre-wrap;    /* Opera 7 */
    word-wrap: break-word;       /* Internet Explorer 5.5+ */

}

这篇关于如何在内容可编辑div中保留空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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