前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >QQ好友界面_qq怎么群发消息给好友列表

QQ好友界面_qq怎么群发消息给好友列表

作者头像
全栈程序员站长
发布2022-09-20 11:19:46
1.4K0
发布2022-09-20 11:19:46
举报
文章被收录于专栏:全栈程序员必看

效果如下:依次为图一—图二—-图三—-图四

QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表
QQ好友界面_qq怎么群发消息给好友列表

主要实现效果:

点击主标题显示下拉好友,再点击收起下拉好友;鼠标移到好友上背景颜色改变;选中的好友背景颜色也要改变;

代码如下:

<!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=”Content-Type” content=”text/html; charset=utf-8″ /> <title>无标题文档</title>

<style type=”text/css”> *{ margin:0px auto; padding:0px; font-family:微软雅黑; font-size:14px; } .zhu{ width:200px; height:30px; text-align:center; line-height:30px; vertical-align:middle; background-color:#03C; color:white; } .zi{ width:200px; display:none} .list{ width:198px; height:30px; text-align:left; line-height:30px; vertical-align:middle; border-left:1px solid #999; border-right:1px solid #999; } .kg{ margin-left: 30px; } .kg1{ margin-left: 10px; } .list:hover{ cursor: pointer; }

#z4{ border-bottom:1px solid #999;} </style>

</head> <body> <div style=”width:200px; height:600px; margin-top:30px”> <div class=”zhu” onclick=”Show(‘z1’)”> 我的好友 </div> <div class=”zi” id=”z1″> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>张三</span></div> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>李四</span></div> </div> <div class=”zhu” onclick=”Show(‘z2’)”> 特别关注 </div> <div class=”zi” id=”z2″> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>王五</span></div> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>陈六</span></div> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>刘二</span></div> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>韩七</span></div> </div> <div class=”zhu” onclick=”Show(‘z3’)”> 陌生人 </div> <div class=”zi” id=”z3″> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>王四</span></div> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>陈三</span></div> </div> <div class=”zhu” onclick=”Show(‘z4’)”> 黑名单 </div> <div class=”zi” id=”z4″> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>刘二</span></div> <div class=”list” onclick=”Xuan(this)” onmouseover=”Bian(this)” onmouseout=”Hui(this)” xz=”0″><span class=”kg”>韩七</span></div> </div> </div> </body> <script type=”text/javascript”>

function Show(id) //作用是收起或显示下拉好友 {

var z = document.getElementById(id);

if(z.style.display==”block”) { z.style.display = “none”; } else { z.style.display = “block”; } }

function Xuan(a) //作用是点击好友,好友背景颜色改变 { var attr = document.getElementsByClassName(“list”);

for(var i=0;i<attr.length;i++) { attr[i].style.backgroundColor = “white”; attr[i].setAttribute(“xz”,”0″); } a.setAttribute(“xz”,”1″); //自定义属性,将XZ属性添加给选中的div a.style.backgroundColor = “#F63”; }

function Bian(a) //作用:鼠标移上背景颜色发生改变 { var attr = document.getElementsByClassName(“list”);

for(var i=0;i<attr.length;i++) { if(attr[i].getAttribute(“xz”)==”0″) { attr[i].style.backgroundColor = “white”; } }

a.style.backgroundColor = “#F63”; }

function Hui(a) //作用是鼠标移走时,背景颜色取消 { var attr = document.getElementsByClassName(“list”);

for(var i=0;i<attr.length;i++) { if(attr[i].getAttribute(“xz”)==”0″) { attr[i].style.backgroundColor = “white”; } } }

</script> </html>

注意:

1、自定义函数运用的形参;

2、为什么不用hover属性,而用onmouseover,onmouseout属性:内嵌样式在js中无法读取。

3、this表示:选中的本div

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/168044.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档