一个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 2013-08-23 16:24  夜渡寒潭  阅读(240)  评论(0编辑  收藏  举报

导航

百科全说 好好生活