zoukankan      html  css  js  c++  java
  • js 获取元素

    <html>
    <head>
    <meta charset="utf-8">
    <title>the test page</title>
    
     
    </head>
    <body style="margin:0;">  
        <div  id="div" style="background:#09F; 200px; margin:auto;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; height:20px;border:1px solid red;">  这是一个可以自适应窗口的DIV   </div>  
        <div class="div1" style="background:#09F; 200px; margin:auto;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; height:20px;border:1px solid red;">  这是一个可以自适应窗口的DIV   </div>  
    
        <div class="div1" style="background:#09F; 200px;  margin:auto;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; height:20px;border:1px solid red;">  这是一个可以自适应窗口的DIV   </div>  
    
     <img src="thinkphp/Public/images/8.jpg" />
     <img src="6.jpg" />
     <img src="7.jpg" />
      
    </body>  
    </html>
    <script>  
    var n=document.getElementsByTagName("img").length;
    var r=document.getElementsByTagName("img");
    var div=document.getElementById("div");
    var div1=document.getElementsByClassName("div1");
    var ll=document.getElementsByClassName("div1").length;
    
    div.onclick=function()
    {
        for(var i=0;i<ll;i++)
        {
          div1[i].style.display="none";
        }
    }
    
    for(var i=0;i<ll;i++)
        {
                   div1[i].onmousemove=function()
                   {
                    
                    this.style.backgroundColor="red";
                    
                   }
                    div1[i].onmouseout=function()
                   {
                    
                     this.style.backgroundColor="#FFF";
                    
                   }
                   
        }
        
        
        
    </script> 
  • 相关阅读:
    nuxt实践
    安卓H5软键盘遮挡输入框
    h5复制粘贴板,打开APP功能
    MVC3
    MVC3
    C#高编
    接口的显式实现(转)
    E-Retail 框架学习
    C#高编
    实现DIV居中布局三种途径(转)
  • 原文地址:https://www.cnblogs.com/benpaodegegen/p/6407785.html
Copyright © 2011-2022 走看看