為什么我這個(gè)代碼運(yùn)行后點(diǎn)擊慕課網(wǎng)卻沒(méi)有跳轉(zhuǎn)??
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無(wú)標(biāo)題文檔</title>
</head>
<body>
<script type="text/javascript">
var main = document.body;
//創(chuàng)建鏈接
function createa(url,text)
{? ?
? ? var url,text;
? ? var newa = document.createElement("a");
? ? newa.setAttribute("href",url);
? ? newa.setAttribute("style","color:red");
? ? var newtext = document.createTextNode(text);
? ? newa.appendChild(newtext);
? ? main.appendChild(newa);
}
// 調(diào)用函數(shù)創(chuàng)建鏈接
createa("http://idcbgp.cn","慕課網(wǎng)");
</script>?
</body>
</html>
2018-04-24
我這里沒(méi)問(wèn)題呀 你再試試?