zoukankan      html  css  js  c++  java
  • 例子:好友列表选中效果

    <style type="text/css">

    *{ margin:0px auto; padding:0px; font-family:微软雅黑; font-size:16px;}

    .f{ 200px; height:30px; background-color:#63C; color:white; text-align:center; line-height:30px; vertical-align:middle; margin-top:3px}

    .f:hover{ cursor:pointer;}

    </style>

    <div style="200px; height:600px; margin-top:30px">      

    <div class="f" onclick="Xuan(this)" onmouseover="Bian(this)" onmouseout="Hui(this)" xz="0">张三</div>    

    <div class="f" onclick="Xuan(this)" onmouseover="Bian(this)" onmouseout="Hui(this)" xz="0">李四</div>    

    <div class="f" onclick="Xuan(this)" onmouseover="Bian(this)" onmouseout="Hui(this)" xz="0">王五</div>    

    <div class="f" onclick="Xuan(this)" onmouseover="Bian(this)" onmouseout="Hui(this)" xz="0">赵六</div>    

    <div class="f" onclick="Xuan(this)" onmouseover="Bian(this)" onmouseout="Hui(this)" xz="0">马七</div>    

    </div>

    <script type="text/javascript">
     
     function Xuan(a)
     {
      var attr = document.getElementsByClassName("f");
      
      for(var i=0;i<attr.length;i++)
      {
       attr[i].style.backgroundColor = "#63C";
       attr[i].setAttribute("xz","0");
      }
      a.setAttribute("xz","1");
      a.style.backgroundColor = "#F63";
     }
     
     function Bian(a)
     {
      var attr = document.getElementsByClassName("f");
      
      for(var i=0;i<attr.length;i++)
      {
       if(attr[i].getAttribute("xz")=="0")
       {
        attr[i].style.backgroundColor = "#63C";
       }
      }
      
      a.style.backgroundColor = "#F63";
     }
     
     
     function Hui(a)
     {
      var attr = document.getElementsByClassName("f");
      
      for(var i=0;i<attr.length;i++)
      {
       if(attr[i].getAttribute("xz")=="0")
       {
        attr[i].style.backgroundColor = "#63C";
       }
      }
     }
     
    </script>

  • 相关阅读:
    在Centos7下源代码安装配置Nginx
    mysql5.7.21源码安装
    数据库设计三大范式
    电商项目中使用Redis实现秒杀功能
    PHP和Redis实现在高并发下的抢购及秒杀功能示例详解
    PHP面向对象(抽象类与抽象方法、接口的实现)
    php面向对象 封装继承多态 接口、重载、抽象类、最终类总结
    利用VHD虚拟文件加密自己的个人信息
    Chrome常用快捷键
    stl本子
  • 原文地址:https://www.cnblogs.com/l5580/p/5909277.html
Copyright © 2011-2022 走看看