• jQuery鼠标事件例子1的改进


    <script type="text/javascript">
    $(function() {
    $("div#leftMenu")
    .css("background-color", "chartreuse")
    .css("border", "dotted thin red")
    .css("width", "280px")

    $("div#leftMenu>ul>li~div")
    .css("display", "none");

    function fnClick() {
    $("div#leftMenu>ul>li~div")
    .css("display", "none");
    $(this).next()
    .css("display", "block");
    }

    $("div#leftMenu>ul>li")
    .bind({
    click: fnClick,
    mouseover: function() {
    $(this)
    .css("background-color", "orange")
    .css("color", "white")
    .css("font-weight", "bold");

    },
    mouseout: function() {
    $(this)
    .css("background-color", "lightskyblue")
    .css("color", "black")
    .css("font-weight", "normal");
    }
    });
    $("dd")
    .bind({
    mouseover: function() {
    $(this)
    .css("background-color", "pink")
    .css("color", "blueviolet")
    .css("font-weight", "bold");
    },
    mouseout: function() {
    $(this)
    .css("background-color", "chartreuse")
    .css("color", "black")
    .css("font-weight", "normal");
    }
    });
    });
    </script>
    <style type="text/css">
    ul {
    padding: 0px;
    margin: 0px;
    }

    li {
    list-style: none;
    padding: 10px;
    margin: 2px;
    text-align: center;
    background-color: lightskyblue;
    }

    dd {
    padding: 4px;
    margin: 3px;
    text-align: center;
    }

    a:hover,
    a:active,
    a:link {
    text-decoration: none;
    color: white;
    }
    </style>
    </head>

    <body>
    <div id="menu">
    <table border="0" cellpadding="0" cellspacing="0">
    <tr style="background-color: darkblue;">
    <th>&nbsp;</th>
    <th width="20">
    <a href="#" onclick="$('#menu').hide();">×</a>
    </th>
    </tr>
    <tr>
    <th colspan="2">
    <div id="leftMenu">
    <ul>
    <li>菜单一</li>
    <div class="subMenu">
    <dd>子菜单11</dd>
    <dd>子菜单12</dd>
    <dd>子菜单13</dd>
    <dd>子菜单14</dd>
    </div>
    <li>菜单二</li>
    <div class="subMenu">
    <dd>子菜单21</dd>
    <dd>子菜单22</dd>
    <dd>子菜单23</dd>
    <dd>子菜单24</dd>
    </div>
    <li>菜单三</li>
    <div class="subMenu">
    <dd>子菜单31</dd>
    <dd>子菜单32</dd>
    <dd>子菜单33</dd>
    <dd>子菜单34</dd>
    </div>
    <li>菜单四</li>
    <div class="subMenu">
    <dd>子菜单41</dd>
    <dd>子菜单42</dd>
    <dd>子菜单43</dd>
    <dd>子菜单44</dd>
    </div>
    <li>菜单五</li>
    <div class="subMenu">
    <dd>子菜单51</dd>
    <dd>子菜单52</dd>
    <dd>子菜单53</dd>
    <dd>子菜单54</dd>
    </div>
    </ul>
    </div>
    </th>
    </tr>
    </table>
    </div>
    <input type="button" value="菜单" onclick="$('#menu').show();" />
    <input type="button" value="撤销" onclick="$('div#leftMenu>ul>li,dd').unbind();" />
    <p>jQuery鼠标事件例子2:在例子1的基础上多运用了bind()--绑定多个事件,在菜单按钮部分运用了show(),在右上角的叉号运用了hide()方法,在撤销按钮运用了unbind()方法--移出事件。</p>
    </body>

  • 相关阅读:
    当函数中传递的参数数量不定时,获取传递给函数的参数信息
    redis分页摘抄
    redis分页
    返回数组中指定的一列,将键值作为元素键名array_column
    PHP操作Redis常用技巧总结
    php面试中的经典问题
    php 依赖注入的实现
    10分钟快速理解依赖注入
    PHP 依赖注入,依赖反转 (IOC-DI)
    PHP控制反转(IOC)和依赖注入(DI)
  • 原文地址:https://www.cnblogs.com/tian-xin/p/8203930.html
Copyright © 2020-2023  润新知