<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.box {
width: 50%;
margin-top: 10%;
margin: auto;
padding: 28px;
height: 350px;
border: 1px #111 solid;
display: none; /* 默认对话框隐藏 */
}
.box.show {
display: block;
}
.box .x {
font-size: 18px;
text-align: right;
display: block;
}
.box input {
width: 80%;
font-size: 18px;
margin-top: 18px;
}
</style>
<script>
var a
function change(n) {
var div= document.getElementById('inputbox');
div.style.display = n ? 'block' : 'none'; /* 点击按钮打开/关闭 对话框 */
if (n) {
a = n.parentNode.getElementsByTagName('a')[0];
ipt = div.getElementsByTagName('input');
ipt[0].value = a.innerHTML;
ipt[1].value = a.href;
}
}
function update() {
var ipt = document.getElementById('inputbox').getElementsByTagName('input');
a.innerHTML = ipt[0].value;
a.href = ipt[1].value;
change();
}
</script>
</head>
<body>
<div>
<table>
<tr>
<td><a href="www.taobao.com" target="_blank">淘宝</a>
<input type="button" οnclick="change(this)" value="修改"></td>
<tr>
<td><a href="www.taobao.com" target="_blank">淘宝</a>
<input type="button" οnclick="change(this)" value="修改"></td>
</tr>
<tr>
<td><a href="www.taobao.com" target="_blank">淘宝</a>
<input type="button" οnclick="change(this)" value="修改"></td>
</tr>
</tr>
</table>
</div>
<div id='inputbox' class="box">
<a class='x' href='' ; οnclick="change(); return false;">关闭</a>
<p>新名称:</p><input type="text">
<p>新网址:</p><input type="text">
<input type="button" value="确定" οnclick="update()">
</div>
</body>
</html>
js修改页面信息
最新推荐文章于 2024-04-27 05:56:04 发布