<!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>
添加回答
举报
0/150
提交
取消