<!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?test?=?document.createElement("a");???????
????test.setAttribute("href",?"url");
????test.innerHTML=text;
????test.style.color="red";
????main.appendChild(test);
}
//?調用函數創建鏈接
createa("http://www.qq.com","騰訊網");
</script>?
<br/>
<input?type="button"?value="創建鏈接"?onclick="createa("http://www.baidu.com","百度")"/>
</body>
</html>
請問點擊按鈕怎么不能創建鏈接?
jzman
2015-10-20 16:38:31