zoukankan      html  css  js  c++  java
  • 封装手风琴!使用jQuery!

     1 //封装手风琴
     2 /**
     3  * 
     4  * 
     5  * 
     6  */
     7 
     8 $.fn.accordion = function (colors, width) {
     9     
    10     var width=width||0;
    11     var colors= colors||[];
    12 
    13     $li = this.find("li");
    14     var boxWidth = this.width();
    15     var avgWidth = boxWidth / $li.length;
    16     var maxWidth = boxWidth - ($li.length - 1) * width;
    17 
    18     //更改li的颜色
    19     $li.each(function (i, e) {
    20         $(e).css("backgroundColor", colors[i]);
    21     });
    22 
    23     //鼠标进入事件
    24     $li.on("mouseenter", function () {
    25         $(this).stop().animate({
    26             "width": maxWidth
    27         }).siblings().stop().animate({
    28             "width": width
    29         });
    30     })
    31     //鼠标离开事件
    32     $li.on("mouseleave", function () {
    33         $li.stop().animate({
    34             "width": avgWidth
    35         });
    36     })
    37     return this;
    38 }

    先提供代码!有时间会更新详细的内容~~~~~~~~~~~

    一份帮助文档,无论多么仔细,都不会帮助主人多敲一行代码!
  • 相关阅读:
    1044 拦截导弹
    3060 抓住那头奶牛 USACO
    2727:仙岛求药(广搜)
    4906 删数问题(另一种贪心思路)
    1004 四子连棋
    1005 生日礼物
    1031 质数环
    1008 选数
    1073 家族
    2801 LOL-盖伦的蹲草计划
  • 原文地址:https://www.cnblogs.com/yaogengzhu/p/9524694.html
Copyright © 2011-2022 走看看