如何改变超链接文本与输入框文本的值
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>
<!-- 改变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>
相关文章推荐
- JavaWeb 之 Cookie详解
- 前段-响应式布局
- C++中extern "C"和export用法
- C#二维数组草稿
- ES5/ES6的区别研究(ECMAScript)
- substr和substring的用法和区别
- sqlite 更换 mysql
- mysql5.6 linux下安装笔记
- MongoDB十分钟搞定CRUD
- BZOJ 4668: 冷战【并查集
- AngularJS $http post 传递参数数据
- mysql in or union 和 unionall 的 浅析
- tomcat8无法远程debug的问题
- 摸爬滚打DirectX11_day04——关于D3D中的AGP内存,系统内存和显存
- capCreateCaptureWindow
- 排序算法整理
- 后摩尔定律时代的最后一块拼图?
- 序列化和反序列化
- [LeetCode]62. Unique Paths
- java中的mvc和三层结构究竟是什么关系