我以前从未使用过任何这样的代码,并且真的不理解如何在提供的代码中使用它。有解决方案吗?
我必须使用的编码:
// get the HTML of "element"
var content = element.innerHTML;
// set the HTML of "otherElement"
otherElement.innterHTML = content;
// JavaScript Document
function myFunction(){
"use strict";
var newpara = document.createElement("p");
var newcontent = document.createTextNode("This is a paragraph.");
// [ADD] Ensure that content is added to the paragraph element
newpara.appendChild(newcontent);
// [ADD] Ensure the paragraph element is added to the document
document.body.appendChild(newpara);
newpara.style.color="#ff3300";
}
<button onClick="myFunction()">Try it</button>