c# - jQuery 加载 txt 文件 .html()

标签 c# javascript jquery asp.net

使用 $('myDiv').load('mytxtFile.txt') 时如何解码 .txt 文件的 html 内容?

我知道:$('<div/>').html(value).text();

换句话说,我如何将这两者结合起来?

重要提示:mytextFile.txt是用ckeditor生成的一些代码的容器,我想在我的html表单中将这个txt文件的内容显示为html表单。

我的txt文件中的代码是:

&lt;p&gt;hellohome&lt;/p&gt;

我想将其显示为:sss hello home sss 在我的 html 页面中

吸引你的注意力

最佳答案

如果我正确理解了这个问题,你可以这样做:

$('myDiv').load('mytxtFile.txt', function(text) {
  $(this).text(text);
});

关于c# - jQuery 加载 txt 文件 .html(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18189522/

相关文章:

c# - 当 native 进程托管 .NET Core 运行时时,在 C# 和 C++ 之间传递 C# 托管实例

c# - 哪个更有效 - Task.Run with 2 awaited I/O bound Tasks, or classic Fork/Join approach?

javascript - 在 d3.js 中的范围的平均值(或中值)处绘制网格线

javascript - Bootstrap v4 : text-only carousel only center text upon sliding completion (sticked to the top otherwise)

php - 提交表单而不刷新页面

javascript - 使用 ajax 传递 # 值不起作用

c# - 使用 ZipFile 在 Windows UWP App 中解压 Zip 存档

c# - await 运算符在 ASP.NET 上的行为与在 ASP.NET CORE 上的行为不同吗?

javascript - 从浏览器中禁用 iOS 双击空格键

Javascript 原型(prototype)和 jQuery