zoukankan      html  css  js  c++  java
  • 鼠标事件和表单事件+好友列表选中效果+侧面菜单下拉效果

    通用:
    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{ 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="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>

    </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{ 200px; height:30px; text-align:center; line-height:30px; vertical-align:middle; background-color:#03C; color:white;}
    .zi{ 200px; display:none}
    .list{ 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="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>

  • 相关阅读:
    1208C Magic Grid
    jsc2019_qualE Card Collector
    jsc2019_qualD Classified
    jsc2019_qualC Cell Inversion
    牛客提高D6t3 分班问题
    牛客提高D6t2 破碎的序列
    牛客提高D6t1 积木大赛
    loj6259「CodePlus 2017 12 月赛」白金元首与独舞
    p4208 [JSOI2008]最小生成树计数
    p4111 [HEOI2015]小Z的房间[简述矩阵树定理]
  • 原文地址:https://www.cnblogs.com/zxl89/p/5912501.html
Copyright © 2011-2022 走看看