<!doctype html>
<!-- 改变a标签的innerHtml内容 -->
<html>
<head>
<title>改变连接标签的innerhtml内容</title>
<style type="text/css">
#topImg{ margin-top:100px;}
#input1{height:25px; width:500px;}
#btn_search{height:30px; width:150px; margin-top:20px;background-color:#03F; color:white;}
#btn_feel{height:30px; width:150px; margin-left:10px; margin-top:20px; background-color:#03F;color:white;}
</style>
<script type="text/javascript">
function search(){
//设置文本框的文本
var input1=document.getElementById("input1");
input1.value="你好";
//这是a1标签的内容
var a1=document.getElementById("a1");
a1.innerHTML="该内容已经被修改";
}
</script>
</head>
<body>
<div>
<center>
<img id="topImg" src="images/QQ图片20161211215954.jpg"/><br/>
<input type="text" id="input1"/><br/>
<input id="btn_search" type="button" value="Google Search" onClick="search();"/>
<input id="btn_feel" type="button" value="I Feeling Lucky"/>
</center>
</div>
<div style="margin-top:40px">
<center>
<a id="a1" href="http://www.baidu.com" style="color:red">百度</a>
</center>
</div>
</body>
</html>
如何改变超链接文本与输入框文本的值
最新推荐文章于 2021-06-03 04:42:40 发布