Document*{padding:0;margin:0;list-style:none;}.list.white{background:#fff}.list{overflow:hidden;position:absolute;top:500px;left:430px;z-index:10}.listli{background:rgba(255,255,255,.3);border:1pxsolid#fff;border-radius:50%;width:15px;height:15px;float:left;margin:5px20px;}.wrap{width:500px;height:500px;margin:10pxauto;overflow:hidden;}.wrap_div{left:0px;width:2000px;height:500px;}.wrap_divdiv{float:left;width:500px;height:500px;position:relative;transition:opacity500msease-in-out;}.wrap_div_one{background:url(https://m.360buyimg.com/babel/jfs/t13342/35/2396024346/99047/e45736fb/5a56bf6eN8cc15233.jpg)no-repeat;background-size:500px500px;left:0;opacity:1;z-index:1}.wrap_div_two{background:url(https://m.360buyimg.com/babel/jfs/t16165/207/1607854073/57122/3438f9c5/5a5ece4fN9efbf994.jpg)no-repeat;background-size:500px500px;left:-500px;opacity:0;z-index:0}.wrap_div_three{background:url(https://img1.360buyimg.com/da/jfs/t17290/105/25936701/79615/ceb9025a/5a5830edNb29eb37c.jpg)no-repeat;background-size:500px500px;left:-1000px;opacity:0;z-index:0}.wrap_div_four{background:url(https://m.360buyimg.com/babel/jfs/t13342/35/2396024346/99047/e45736fb/5a56bf6eN8cc15233.jpg)no-repeat;background-size:500px500px;left:-1500px;opacity:0;z-index:0}$(document).ready(function(){varval=0;vartimer;functionmove(){$('.wrap_divdiv').css({opacity:0,zIndex:0});$('.listli').removeClass('white');val++;***if(val==3){$('.listli').eq(0).addClass('white');}elseif(val>3){val=1;}$('.listli').eq(val).addClass('white');***$('.wrap_divdiv').eq(val).css({opacity:1,zIndex:1});//$('.wrap_div').css({left:val*500*-1});timer=setTimeout(move,6000)}setTimeout(move,3000)})這是我仿照京東頁(yè)面寫(xiě)的輪播圖。請(qǐng)問(wèn)JS那個(gè)部分$('.listli').eq(0).addClass('white')。if內(nèi)部的執(zhí)行代碼。請(qǐng)問(wèn)為什么執(zhí)行了$('.listli').eq(0).addClass('white')這句之后。并不會(huì)被后面的$('.listli').eq(val).addClass('white')這句的效果給覆蓋掉。這是為什么啊、按照從上到下的執(zhí)行順序應(yīng)該會(huì)覆蓋才對(duì)。
js執(zhí)行順序問(wèn)題
BIG陽(yáng)
2019-05-24 15:51:10