qq_封Y_0
2015-08-10 16:49
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
var main = document.body;
//创建链接
function createa(url,text)
{
var addhref=document.createElement("a");
addhref.setAttribute("href",url);
addhref.setAttribute("text","http://www.immoc.com");
addhref.setAttribute("color",red);
main.appendChild(addhref);
}
// 调用函数创建链接
createa("http://www.imooc.com/","慕课网");
</script>
</body>
</html>
red应该是"red"
addhref.setAttribute("color","red");addhref.innerHTML = "imooc";//加一句这个
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题