我正在制作一个网页,将得到它自己的html代码,然后,替换所有有害的html代码,如<
和>
,并将它们更改为ascii对应,所以它不会倾斜它,但它看起来也写给用户。js拆分,在行尾
我需要使用断线的html代码<br />
或其他方式来sperate的线条,由乙醚,我知道我有多少行必须使用themehtml.split("\n");
所以,问题是“我需要一种方法来在该行”
这是末尾添加一个换行符我最我的js代码样的帮助的问题有点
$(".edit_html_button").click(function()
{
var themehtml = $(".wrapper").html();
var oldhtml = _grubber_blog.html();
themehtml = themehtml.replace(/</g, "<"); //slowly removing html codes
themehtml = themehtml.replace(/>/g, ">"); //slowly removing html codes
themehtml = themehtml.split(' ').join(' ');//slowly removing html codes
themehtml = ("<div class='numberboxleft'></div><div class='edit_theme' contenteditable='true'>"+themehtml+"</div>");
themehtml = themehtml.split("\n");
//alert(themehtml);
_grubber_blog.css("background-color", "#fff");
$("#tiptip_holder").remove();
$("._grubber_blog_customize").html(" ");
$("._grubber_blog_customize").html(themehtml);
//adds the numbers up the left side
var e = 0;
var lenght = themehtml.length;
var numbers = "";
while (e < lenght){
numbers = $(".numberboxleft").html();
$(".numberboxleft").html(numbers + e + "<br />");
e++;
}
});
我找到了答案,我会后对某些人 – ryanc1256
'themehtml.split( “\ n”)。JOIN( '
')' – adeneo
妈呀,这是简单的,我一直在坚持在这上半小时哦,不...... :-D,谢谢@adeneo – ryanc1256