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>
  • 相关阅读:
    杭电ACM 1197
    杭电ACM 1196
    杭电ACM题目分类
    杭电ACM 1178
    指针转化(二重)
    怎么查看一个类的内存分布
    how find out what is causing Visual Studio to think each project is out of date
    MSB8013
    File mapping
    SHFileOperation 解决double-null terminated
  • 原文地址:https://www.cnblogs.com/lxabner/p/12340778.html
Copyright © 2011-2022 走看看