一个js,记录方便查询。

var foucs_a = {
    createNew: function(){
        var cls = {
            par_id:'',
            cur_pos:1,
            cur_id:'',
            count:3,
            timer:null,
            _init: function(id, count) {
                var mouseover = function(evt) {
                    if(jQuery(this).attr('id') && !jQuery(this).hasClass("a")) {
                        // 分拆并得到该id
                        var tmp = this.id.split("_");
                        var _obj = cls;
                        _obj.cur_pos = tmp[tmp.length-1];
                        _obj.cur_id = this.id;
                        _obj.active();
                    }
                };
                var par_mouseover = function(evt) {
                    var _obj = cls;
                    clearInterval(_obj.timer);
                }
                var par_mouseout = function(evt) {
                    var _obj = cls;
                    clearInterval(_obj.timer);
                    _obj.timer = setInterval(function(){_obj.next()}, 2000);
                }
                this.par_id = id;
                this.count = count;
                jQuery("#"+id+" li").bind('mouseover', mouseover);
                jQuery("#"+id+"_cnt").bind('mouseover', par_mouseover);
                jQuery("#"+id+"_cnt").bind('mouseout', par_mouseout);
 
                var me = this;
 
                this.timer = setInterval(function(){me.next()}, 2000);
            },
            next: function() {
                this.cur_pos++;
                if (this.cur_pos>this.count) {this.cur_pos = 1};
                this.active();
                //alert(this.cur_pos);
            },
            active: function() {
                jQuery("#"+this.par_id+" li").removeClass("a");
                jQuery("#"+this.par_id+"_"+this.cur_pos).addClass("a");
                jQuery("#"+this.par_id+"_cnt .bttab_one").hide();
                jQuery("#"+this.par_id+"_"+this.cur_pos+"_cnt").show();
            }
        };
 
        return cls;
    }
};

  

posted on   夜渡寒潭  阅读(240)  评论(0编辑  收藏  举报

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
百科全说 好好生活
点击右上角即可分享
微信分享提示