这是我的代码:
console.log($('p').html())
<p><span data-htmlContent="<p>This is not really in a p tag.</p>">.</span>.</p>
在 Chrome 和更早的 FireFox 中,控制台记录:<span data-htmlcontent="<p>This is not really in a p tag.</p>">.</span>.
但在 IE 和较新的 FireFox 中它记录:<span data-htmlcontent="<p>This is not really in a p tag.</p>">.</span>.
问题可以在这里看到:http://jsfiddle.net/Nzj52/9/
最佳答案
与渲染操作相比,这可能与每个浏览器控制台的操作方式有关。如果您这样做并改为提醒 - 您的答案会改变吗?
而不是调用 console.log($('p').html()); 尝试调用 console.log($('p').text());
关于javascript - 在某些浏览器中,转义的 html 字符未被 jquery .html() 转义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20101497/