我正在尝试在变量中保存一些HTML(来自XML文件),但不知何故,我收到了一些奇怪的错误。除此之外,即使我不使用它,浏览器似乎也会尝试加载这段HTML代码中使用的图像。将HTML保存在变量中的JavaScript
下面的代码:
// Load the data from the XML node.
var description = $(this).find('description').text();
var descriptionWithTags = description.replace('<p>','');
descriptionWithTags = descriptionWithTags.replace('</p>','########');
// Remove HTML Tags and add the Line-Breaks
var convertedString = $(descriptionWithTags).text();
convertedString = convertedString.replace('########','<br /><br />');
console.log("E");
// Save it in an array.
contentRSS[articleCount] = convertedString;
编辑:如果我删除以下行,它再次工作,但我现在为什么不。
descriptionWithTags = descriptionWithTags.replace('<p>','');
...,什么是这些难以捉摸的'怪errors'? –
它说jquery.js中有错误,但是显示的是我加载的html内容的一部分。它看起来像是在混合一些东西。 –