為什么我的“創(chuàng)建”鏈接按鈕無(wú)效呢?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;?
charset=gbf-32">
<title>無(wú)標(biāo)題文檔</title>
</head>
<body>
<script type="text/javascript">
var main1 = document.body;
//創(chuàng)建鏈接
function createa(url,text)
{
? ? var alink = document.createElement("a");
? ? alink.setAttribute("href",url);
? ? alink.innerHTML=text;
? ? main1.appendChild(alink);
? ? return alink;
? ??
? ??
}
// 調(diào)用函數(shù)創(chuàng)建鏈接
main1.appendChild(createa("http://idcbgp.cn","慕課網(wǎng)"));
</script>?
<input type="button" value="創(chuàng)建" onclick="createa
("http://idcbgp.cn","慕課網(wǎng)")"></input>
</body>
</html>
2016-07-27
<input type="button" value="創(chuàng)建" onclick='createa("http://idcbgp.cn","慕課網(wǎng)")' / >
2016-07-27
onclick里面寫錯(cuò)了,應(yīng)該是
里面不能用雙引號(hào)