换行符不会在文字区域在IE中显示 [英] Line breaks won't display in textarea in IE

查看:310
本文介绍了换行符不会在文字区域在IE中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery的 .load()方法,我加载文本到一个textarea。工作正常,在Chrome浏览器和FF。与往常一样,IE浏览器只是要有所不同,并不会显示换行。

Using jQuery's .load() method I'm loading text into a textarea. Works fine in Chrome & FF. As always, IE just has to be different and won't display the line breaks.

我已经试过空格:pre-包装,没有运气

任何想法?

我的code:

$('#textarea').load('data.php');

data.php 简单地查询MySQL数据库,并打印出结果。

The data.php simply queries a MySql database and prints the results.

推荐答案

与IE浏览器使用的innerHTML()的了解更多的详细信息。作为jQuery的html的()和.load()方法都使用的innerHTML(),它们通过延长可能会导致一些问题。 一种解决方案是使用的.text()代替。如果要加载文成< textarea的> 使用AJAX和jQuery你需要做的是这样的:

Thery're compatibility problems with IE when using innerHTML(), read for more details. As Jquery's .html() and .load() methods both use innerHTML() ,they by extension can result in some issues. One solution is to use .text() instead. If you want to load text into a <textarea> using AJAX and Jquery you need to do something like this:

$('#textarea').post('data.php',function(data){
        $(this).text(data);
    })
);

这篇关于换行符不会在文字区域在IE中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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