今天用到了switch,虽然之前几百年前学过,不过早忘了。
现在应该算是真正掌握
switch(i)
{
case 0:
zo1a.eq(0).css(“background-position”,”0px 0px”);
zo1a.eq(3).css(“background-position”,”-292px -138px”);
zo1a.eq(4).css(“background-position”,”-292px -184px”);
zo1a.eq(5).css(“background-position”,”-292px -230px”);
zo1a.eq(1).css(“background-position”,”-292px -46px”);
zo1a.eq(2).css(“background-position”,”-292px -92px”);
break
case 1:
zo1a.eq(0).css(“background-position”,”-292px 0px”);
zo1a.eq(2).css(“background-position”,”-292px -92px”);
zo1a.eq(3).css(“background-position”,”-292px -138px”);
zo1a.eq(4).css(“background-position”,”-292px -184px”);
zo1a.eq(5).css(“background-position”,”-292px -230px”);
zo1a.eq(1).css(“background-position”,”0px -46px”);
break
case 2:
zo1a.eq(0).css(“background-position”,”-292px 0px”);
zo1a.eq(3).css(“background-position”,”-292px -138px”);
zo1a.eq(4).css(“background-position”,”-292px -184px”);
zo1a.eq(5).css(“background-position”,”-292px -230px”);
zo1a.eq(1).css(“background-position”,”-292px -46px”);
zo1a.eq(2).css(“background-position”,”0px -92px”);
break
case 3:
zo1a.eq(0).css(“background-position”,”-292px 0px”);
zo1a.eq(3).css(“background-position”,”0px -138px”);
zo1a.eq(4).css(“background-position”,”-292px -184px”);
zo1a.eq(5).css(“background-position”,”-292px -230px”);
zo1a.eq(1).css(“background-position”,”-292px -46px”);
zo1a.eq(2).css(“background-position”,”-292px -92px”);
break
case 4:
zo1a.eq(0).css(“background-position”,”-292px 0px”);
zo1a.eq(3).css(“background-position”,”-292px -138px”);
zo1a.eq(4).css(“background-position”,”0px -184px”);
zo1a.eq(5).css(“background-position”,”-292px -230px”);
zo1a.eq(1).css(“background-position”,”-292px -46px”);
zo1a.eq(2).css(“background-position”,”-292px -92px”);
break
case 5:
zo1a.eq(5).css(“background-position”,”0px -230px”);
zo1a.eq(0).css(“background-position”,”-292px 0px”);
zo1a.eq(3).css(“background-position”,”-292px -138px”);
zo1a.eq(4).css(“background-position”,”-292px -184px”);
zo1a.eq(1).css(“background-position”,”-292px -46px”);
zo1a.eq(2).css(“background-position”,”-292px -92px”);
break
default:
};
我这里default没有写,其实可以当作一个case用的。比如case0;或者其他更高级用法。
break后面可以不需要加分号。以前记得好像要分号。呵呵。