<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>动态添加链接</title>
<script type="text/
javascript">
function AppendLink() {
var div = document.getElementById("divMain");
var linkTmp = document.createElement("a");
linkTmp.href = "http://www.jb200.com";
linkTmp.innerText = "脚 本 学 堂"; //链接要使用innertText,不能使用value
div.appendChild(linkTmp);
}
</script>
</head>
<body>
<div id="divMain"></div>
<input type="button" value="添加链接" onclick="AppendLink()" />
</body>
</html>
<script type="text/javascript" language="javascript">
function changeslt() {
var a = document.getElementById("lk");
var pindex = document.form1.slt.value;
alert(pindex);
if (pindex == 1) {
a.href = "www.baidu.com";
}
else {
a.href = "www.google.cn";
}
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<div>
<select name="slt" onchange="changeslt()">
<option value="1">选择
百度</option>
<option value="2">选择谷歌</option>
</select>
<a href="www.baidu.com" id="lk">点击连接</a>
</div>
</form>
</body>