"-6ren"> "-我有一个文本区域。在其点击事件上。我将其插入数据库中,然后将其显示为元素列表中的第一个元素。问题是。如果我输入""在textarea中,jquery无法正确显示。它显示为空。代码是 var note -6ren">
cuốn sách gpt4 ai đã làm

javascript - Jquery 转义 "<" ">"

In lại Tác giả: Walker 123 更新时间:2023-11-28 12:29:33 29 4
mua khóa gpt4 Nike

我有一个文本区域。在其点击事件上。我将其插入数据库中,然后将其显示为元素列表中的第一个元素。问题是。如果我输入""在textarea中,jquery无法正确显示。它显示为空。代码是

var note = $.trim( $('#rep_notes_add_notes').val());
if(note == "")
trả về sai;
$.ajax({
url: 'include/tre.ajax.php',
gõ: 'BÀI ĐĂNG',
dữ liệu: {
action: 'insert',
note: note
},
dataType: 'json',
success: function(data) {
jQuery("#rep_notes_add_notes").val('');
jQuery(".no_notes").remove();
*$(".notes:eq(0)").before('
'+note+'
Added by '+user +' on '+data.update_time+'
');*
}
});

标记为*的行找到notes div,然后在其前面插入一个元素以显示新输入的文本。

有人可以帮我解决这个问题吗?

câu trả lời hay nhất

它不显示它,因为它认为 是标签,不是文本。您需要更改 <ĐẾN<来显示它。

var str = "";
var escaped = str.replace(/&/g,"&").replace(//g,">");

关于javascript - Jquery 转义 "<" ">",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23501548/

29 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress