问问题
1519 次
1 回答
1
我会使用.text()。尝试这个:
$(document).ready(function () {
var text_area = $("#code_window");
$("button#setup").click(function () {
$(text_area).text("<!DOCTYPE html>" + "\n" + "<html>" + "\n" + "<head>" + "\n\t\n" + "</head>" + "\n" + "<body>" + "\n\t\n" + "</body>" + "\n" + "</html>");
});
$("button#add_p").click(function () {
var txt = $("#code_window").val();
var new_txt = txt.replace('</body>', '<p>' + '\n' + '</p>' + '\n' + '</body>');
$(text_area).text(new_txt);
});
});
小提琴
于 2013-10-09T06:05:46.183 回答