多行注释问题jquery
问题描述:
我在网站上制作了一大串图片的图片网站,每张图片下面都有可能评论图片,然后在没有页面加载和评论内容的情况下显示评论,问题是当我有很长的评论打破当前行,他们不显示,因为我的评论框CSS溢出隐藏。下面是例子:多行注释问题jquery
这是一个注释 - 这是显示 正确
这是一个注释这是一个 评论这是一个注释 - 这是 ,因为它打破无法正常
显示线。下面是该jQuery代码:
$.ajax({
type: "POST",
url: "<?=base_url()?>imagesform/post_comment",
data: datas,
success: function() {
$("#image-comments-" + image_id).attr("class", "comments");
$("#image-comments-" + image_id).append("<li id=\"new_append_" + image_id+ "\">" + $("#image").find(".comment").val() + "</li>").children(':last').height($('.comments li:last').height()).hide().slideDown(500, function() {
var bodyHeight = $('html').height();
$('.addComment').fadeOut(300, function() {
$('html').height(bodyHeight);
});
});
alert($("#image").find(".comment").val());
}
});
这里$("#image").find(".comment").val()
在其评论输入,当我提醒它整个多行输入的文本区域的价值在那里把它的不被追加到李正确,这是我感到困惑时的一部分,任何建议为什么只有部分输入的字符串被附加?
答
这就是答案,高度上当了因为某些原因:
$("#image-comments-" + image_id).append("<li id=\"new_append_" + image_id+ "\" style=\"height:auto !important;\">"
新增height:auto !important;
CSS属性为新创建的李
答
对我来说就像你想用<br>
替换换行符来通过HTML显示它们。
alert($("#image").find(".comment").val().replace('\n', '<br>'));
我已经试过了吧 – ant 2010-05-08 09:34:05