码迷,mamicode.com
首页 > 其他好文 > 详细

好友列表选中

时间:2018-01-01 23:39:43      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:height   type   for   charset   utf-8   over   ddl   技术分享   ant   

好友列表选中:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>好友列表选中</title>
<style type="text/css">
*{margin:0px auto; padding:0px;}
.aa{ width:200px; height:250px;}
.ss{ width:200px; height:50px; background-color:#0F0; color:#003;
text-align:center; line-height:50px; vertical-align:middle; margin-top:5px}
.ss:hover{ background-color:#00F !important; color:#fff !important; cursor:pointer;}
</style>
</head>

<body>
    <div class="aa">
        <div class="ss">刘一</div>
        <div class="ss">陈二</div>
        <div class="ss">张三</div>
        <div class="ss">李四</div>
        <div class="ss">王五</div>
    </div>
    
<script type="text/javascript">
 var ss = document.getElementsByClassName("ss")
   for(var i=0;i<ss.length;i++)
   {
       ss[i].onclick = function()
       {
        for(var i=0;i<ss.length;i++)
         {
           ss[i].style.backgroundColor = "#0f0";
           ss[i].style.color = "#003";
       }
       this.style.backgroundColor = "#00f";
       this.style.color = "#fff";
       }
   }
</script>
</body>
</html>

效果图:

技术分享图片

技术分享图片

 

好友列表选中

标签:height   type   for   charset   utf-8   over   ddl   技术分享   ant   

原文地址:https://www.cnblogs.com/Whitehat/p/8168948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!