zoukankan      html  css  js  c++  java
  • JS隐藏显示图片

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>  
    </head>
    <body>
        <button id="btn">隐藏</button>
        <br>
        <img src="img/1.jpeg" id="new">
        <script>
            var obtn=document.getElementById('btn');
            var img=document.getElementsByTagName('img')[0];
            //获取出img集合中的索引为0的照片
            obtn.onclick=function(){
                if(obtn.innerHTML=='隐藏')
                {
                img.style.display='none';
                obtn.innerHTML="显示";
                如果相等则改变obtn的文字为显示
                }
                else
                {
                    img.style.display='block';
                    obtn.innerHTML="隐藏";
                如果不相等则改变obtn的文字为隐藏
                }

            }

        </script>
    </body>
    </html>
  • 相关阅读:
    五种I/O模型
    Python socket服务
    Python 协程
    python openpyxl 简单使用
    python 文件夹压缩
    Python 多进程
    MySQL 自定义函数
    python 队列
    python 多线程、线程锁、事件
    python paramiko模块:远程连接服务器
  • 原文地址:https://www.cnblogs.com/lxabner/p/12340778.html
Copyright © 2011-2022 走看看