【发布时间】:2020-07-23 14:13:08
【问题描述】:
我的输入是一个包含 windows 文件路径的 json。我想在 html 中显示文件路径。请注意,我无法更改输入字符串。有人知道我可以对输入字符串执行什么操作,以便在我的 html 页面中显示反斜杠吗?我已经搜索了很多问题,但我似乎没有找到解决这个问题的方法。
// The json would be something like this.
data = [
{"name": "Something", "link": "C:\something\something"},
{"name": "Something Else", "link": "C:\something\something_else"}
];
// Loop over the json and add the elements to the html afterwards
var list = '';
$.each(data, function () {
list += `
<p> ${this.name} </p>
<input class="form-control" type="text" value="${this.link}">
`;
});
$(".some-container").html(list);
当我使用此代码时,不显示反斜杠。
【问题讨论】:
标签: javascript jquery string escaping backslash