一个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; } }; |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步