JS实例之列表选中,实现类似好友列表选中效果

 1 <head>
 2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 3 <title>无标题文档</title>
 4 <style type="text/css">
 5 *{margin:0px auto; padding:0px;}
 6 #wai{width:100px; height:110px; margin-top:50px;}
 7 .list{width:100px; height:20px; background-color:#999; text-align:center; line-height:20px; vertical-align:middle; margin:2px; color:#FFF;}
 8
 9 </style>
10 </head>
11
12 <body>
13     <div id="wai">
14         <div class="list" onclick="dian(this)" onmouseover="show(this)" xz="0" onmouseout="huifu(this)">甲</div>
15         <div class="list" onclick="dian(this)" onmouseover="show(this)" xz="0" onmouseout="huifu(this)">乙</div>
16         <div class="list" onclick="dian(this)" onmouseover="show(this)" xz="0" onmouseout="huifu(this)">丙</div>
17         <div class="list" onclick="dian(this)" onmouseover="show(this)" xz="0" onmouseout="huifu(this)">丁</div>
18         <div class="list" onclick="dian(this)" onmouseover="show(this)" xz="0" onmouseout="huifu(this)">未</div>
19     </div>
20
21 </body>
22 <script type="text/javascript">
23 function dian(a){
24     var sy=document.getElementsByClassName("list");
25     for(i=0;i<sy.length;i++){
26         sy[i].style.backgroundColor ="#999";
27         sy[i].style.color ="#FFF";
28         sy[i].setAttribute("xz","0");
29     }
30     a.style.backgroundColor ="white";
31     a.style.color ="black";
32     a.setAttribute("xz","1");
33 }
34 function show(b){
35     var sy=document.getElementsByClassName("list");
36     for(i=0;i<sy.length;i++){
37         if(sy[i].getAttribute("xz")=="0"){
38             sy[i].style.backgroundColor ="#999";
39             sy[i].style.color ="#FFF";
40         }
41     }
42     b.style.backgroundColor ="white";
43     b.style.color ="black";
44 }
45 function huifu(){
46     var sy=document.getElementsByClassName("list");
47     for(i=0;i<sy.length;i++){
48         if(sy[i].getAttribute("xz")=="0"){
49             sy[i].style.backgroundColor ="#999";
50             sy[i].style.color ="#FFF";
51         }
52     }
53 }
54 </script>
55 </html>

时间: 2024-08-20 18:19:25

JS实例之列表选中,实现类似好友列表选中效果的相关文章

JS实例之图片轮播,实现图片播放效果

1 <head> 2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 3 <title>无标题文档</title> 4 <style type="text/css"> 5 *{margin:0px auto;padding:0px;} 6 #wai{width:500px;height:200px

iOS TableView实现QQ好友列表(一)

一,创建项目 二,创建所需属性及实现列表 首先给ViewController创建两个属性 UITableView *tableView;//展示列表 NSArray *titleArray;//第一层列表需要展示的数据 初始化 tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; tableView.showsVerticalScrollIndicator=NO; t

JS练习题 ( 下拉菜单;好友选中输入)

题一.左侧菜单下拉 做题思路:先做菜单和子菜单,把子菜单默认隐藏.再用JS调样式. <style type="text/css">*{ margin:0px auto; padding:0px}.text1{ width:180px; height:39px; border-bottom:1px solid white; text-align:center; line-height:40px; vertical-align:middle; color:white}.text

基于Qt的类似QQ好友列表抽屉效果的实现

前段时间在忙毕业设计,所以一直没有更新博客.今天答辩完以后,将对我的毕业设计进行模块展示,供Qt初学者进行参考. 毕业设计题目:Linux系统下基于Qt的局域网即时通信系统设计与实现 其中我有一个类似于QQ的好友列表,然后对好友可以进行分组管理,毕设中具体效果图如下: 网上查寻到的设计思路: 1.采用QToolBox的方式,虽然看起来有点样子,但是并不是我们所熟悉的好友列表,比如:http://blog.csdn.net/qianguozheng/article/details/6719074

[百度地图] 用于类似 DWZ UI 框架的 百度地图 功能封装类 [MultiZMap.js] 实例源码

MultiZMap 功能说明 MultiZMap.js 本类方法功能大多使用 prototype 原型 实现,它是 ZMap 的多加载版本,主要用于类似 DWZ 这个 多标签的 UI 的框架: 包含的功能有:轨迹回放,圈画区域可编辑,判断几个坐标是否在一个圆圈内,生活服务查询,从经纬度获取地址信息,地图工具包括测距,获取面积,以积打印地图,地图全屏,实时路况,坐标是否在polygon区域内,打车方案,经过中间途经点,添加地图控件: 界面查看 : http://www.cnblogs.com/ed

鼠标事件和表单事件+好友列表选中效果+侧面菜单下拉效果

通用:onclick 鼠标单击ondblclick 鼠标双击onmouseover 鼠标放上onmouseout 鼠标离开onmousemove 鼠标移动 表单:onchang 表单的值改变onblur 失去焦点onfocus 获得焦点onselect 选中 2.好友列表选中效果 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/

JavaScript实现的购物车效果-好友列表效果

JavaScript实现的购物车效果,当然这个效果可以运用在好多地方,比如好友的选择,人力资源模块,计算薪资,人员的选择等等.下面看类似某种购物车的效果图: code: goodsCar.js:这个js写成了一个单独的文件.主要是控制上面的列表显示的. window.onload=function(){ initStore(); }; var goods=["火腿","美女","御姐","火星一日游","跑车&quo

练习数据库和网页布局(查询好友列表)

学习:查询好友列表 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=&quo

JavaScript、jQuery、HTML5、Node.js实例大全-读书笔记3

技术非常多,样例非常多.仅仅好慢慢学,慢慢实践!!如今学的这本书是[JavaScript实战----JavaScript.jQuery.HTML5.Node.js实例大全] JavaScript.jQuery.HTML5.Node.js实例大全-读书笔记2 3.3 响应鼠标动作 图3-2的效果已经有了,须要鼠标来操作展示想看的照片.这就须要在对应的地方加上事件. 3.3.1 响应小照片单击动作 在3.2.3的代码里提供了显示小图列表的eg.showThumb()方法.在单击小图片时要显示大图片.