您的位置:首页 > 其它

如何改变超链接文本与输入框文本的值

2016-12-12 17:24 375 查看
<!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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: