functionCatCreateShades(o){this.dom =$(o.dom);this.data = o.data;this.llist=[];this.init();}CatCreateShades.prototype.init=function(){let that =this;let dis = that.dom.width()/that.data.length;for(let i =0;i<that.data.length;i++){
that.llist.push(i*dis);$("<img style='left:"+i*dis+"px;' src='"+that.data[i]+"'>").hover(function(){// 根据真实数据结构更改
that.dom.find("img").eq(i).css({"left":"0px","z-index":"9"})},function(){for(let a =0;a<that.llist.length;a++){
that.dom.find("img").css("z-index","0").eq(a).css("left",that.llist[a]+"px")}}).appendTo(that.dom);}}
使用(js)
let data =["./resources/01.jpg","./resources/02.jpg","./resources/03.jpg","./resources/04.jpg","./resources/05.jpg","./resources/06.jpg","./resources/07.jpg"];newCatCreateShades({dom:".box",data:data})