慕粉2225318466
2017-02-26 13:59
var mian = document.body;
function createa(url,text) {
var alink=document.createElement("a");
alink.setAttribute("href",url);
alink.setAttribute("value",text);
alink.setAttribute("color","purple");
main.appendChild(alink); }
// 调用函数创建链接
createa("http://www.imooc.com","慕课网");
//哪里出问题了呢?
var mian = document.body; //你下面调用的是main ,而你这里写成了mian
function createa(url,text) {
var alink=document.createElement("a");
alink.setAttribute("href",url);
alink.setAttribute("value",text);
//文本内容用innerHTML alink.innerHTML=text;
alink.setAttribute("color","purple");
//颜色要用.style alink.style.color = "purple" ;
main.appendChild(alink);
}
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题