課程
/前端開發(fā)
/JavaScript
/焦點(diǎn)圖輪播特效
制作輪播圖然后點(diǎn)擊沒效果
2017-04-25
源自:焦點(diǎn)圖輪播特效 4-1
正在回答
window.onload?=?function(){ var?g?=?function(idx)?{ return?document.getElementById(idx); } var?container?=?g('container'), list?=?g('list'), buttons?=?g('buttons').getElementsByTagName('span'), prev?=?g('prev'), next?=?g('next'), index?=?1; function?showBtn()?{ var?i?=?0, len?=?buttons.length; for(;i<len;)?{ if(buttons[i].className?==?'on')?{ buttons[i].className?=?''; } i++; } buttons[index?-?1].className?=?'on'; } function?animate(offset)?{ var?newLeft?=?parseInt(list.style.left)?+?offset; list.style.left?=?newLeft?+?'px'; if(newLeft?>?-600)?{ list.style.left?=?-3000?+?'px'; } if(newLeft?<?-3000)?{ list.style.left?=?-600?+?'px'; } } next.onclick?=?function?()?{ if(index?>=?buttons.length)?{ index?=?1; }?else?{ index?+=?1 } animate(-600); showBtn(); //list.style.left?=?parseInt(list.style.left)?-?600?+?'px'; } prev.onclick?=?function(){ if(index?<=?1)?{ index?=?buttons.length; }?else?{ index?-=?1; } animate(600); showBtn(); //list.style.left?=?parseInt(list.style.left)?+?600?+?'px'; } }
看看代碼有沒有打錯(cuò)
舉報(bào)
通過本教程學(xué)習(xí)您將能掌握非常實(shí)用的焦點(diǎn)圖輪播特效的制作過程
2 回答為什么判斷語(yǔ)句寫在點(diǎn)擊事件函數(shù)體內(nèi)沒有效果?如果要寫在點(diǎn)擊事件函數(shù)體內(nèi)該怎樣寫?
2 回答為什么箭頭切換沒效果
2 回答為什么我的動(dòng)畫效果沒有反應(yīng)??
2 回答點(diǎn)擊id為next的元素它的left會(huì)-510px,為什么我這個(gè)代碼實(shí)現(xiàn)不了這個(gè)效果?
3 回答點(diǎn)擊NEXT了為什么圖片沒有進(jìn)入下一張呢?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-08-06
2017-04-26
看看代碼有沒有打錯(cuò)