首页 > 代码库 > 鼠标事件和表单事件+好友列表选中效果+侧面菜单下拉效果

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

通用:
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/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:16px;}

.f{ width: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>

</head>

<body>

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

<div class="f" onclick="Xuan(this)" onm ouseover="Bian(this)" onm ouseout="Hui(this)" xz="0">张三</div>
<div class="f" onclick="Xuan(this)" onm ouseover="Bian(this)" onm ouseout="Hui(this)" xz="0">李四</div>
<div class="f" onclick="Xuan(this)" onm ouseover="Bian(this)" onm ouseout="Hui(this)" xz="0">王五</div>
<div class="f" onclick="Xuan(this)" onm ouseover="Bian(this)" onm ouseout="Hui(this)" xz="0">赵六</div>
<div class="f" onclick="Xuan(this)" onm ouseover="Bian(this)" onm ouseout="Hui(this)" xz="0">马七</div>

</div>

 

</body>
<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>
</html>

2.左侧下拉列表

技术分享

<!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:center; line-height:30px; vertical-align:middle; border-left:1px solid #999;border-right:1px solid #999;}
#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">你好</div>
<div class="list">首页</div>
</div>
<div class="zhu" onclick="Show(‘z2‘)">
教务信息
</div>
<div class="zi" id="z2">
<div class="list">你好</div>
<div class="list">首页</div>
</div>
<div class="zhu" onclick="Show(‘z3‘)">
下载专区
</div>
<div class="zi" id="z3">
<div class="list">你好</div>
<div class="list">首页</div>
</div>
<div class="zhu" onclick="Show(‘z4‘)">
学员信息管理
</div>
<div class="zi" id="z4">
<div class="list">你好</div>
<div class="list">首页</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";
}
}

</script>
</html>

 

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