我正在尝试以这种方式写入文档。我不使用的原因document.getElementById("holder").innerHTML="x"
是因为有机会我会写不止一次,并且不希望任何内容被覆盖。然而,这种方法的问题在于,当我希望包含在字符串中的标签工作时,文本内容被视为文字字符串。我应该如何更改此代码以使标签正确显示在文档上?
if (office1match == matchindex[0]) {
var newParagraph = document.createElement('article');
newParagraph.textContent = "<p class=\"title\">Core i.1.1</p><img class=\"caseimg\" src=\"images\\case1.png\"><p><span class=\"bold\">Motherboard:</span> ASRock H61M/U3S3 LGA 1155 Intel H61</br><span class=\"bold\">Processor:</span> Intel Celeron G550 Sandy Bridge 2.6GHz LGA 1155 65W</br><span class=\"bold\">Video Card:</span> On Board</br><span class=\"bold\">Memory:</span> Crucial 2GB (2 x 1GB) 240-Pin DDR3 SDRAM DDR3 1333</br><span class=\"bold\">DVD Burner:</span> ASUS 24X DVD Burner</br><span class=\"bold\">Hard Drive:</span> Western Digital Caviar Blue WD2500AAKX 250GB 7200 RPM</br><span class=\"bold\">Case:</span> Rosewill R363-M-BK Black Ultra High Gloss Finished MicroATX</br><span class=\"bold\">OS:</span> Microsoft Windows 7 Home Premium</br><span class=\"bold\">Cost:</span> $430.00</p>";
document.getElementById("holder").appendChild(newParagraph);
}