js修改页面信息

<!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>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值