setattribute()不能設(shè)置innerHTLM屬性??????
var main = document.body;
//創(chuàng)建鏈接
var a=document.createElement("a");
a.setAttribute("href","http://idcbgp.cn/");
a.setAttribute("innerHTML","慕課網(wǎng)");
//a.setAttribute("style","color:red");
main.appendChild(a);
2017-02-11
innerHTML 不是標(biāo)簽的屬性 ? 要添加內(nèi)容的話 ?可以創(chuàng)建文本節(jié)點(diǎn)?
?var text=document.createTextNode("慕課網(wǎng)");
a.appendChild(text);
2017-02-11
或者直接寫(xiě) a.innerHTML="慕課網(wǎng)";