本文實(shí)例講述了jQuery實(shí)現(xiàn)最簡單的切換圖效果。分享給大家供大家參考,具體如下:
<!DOCTYPE html><html lang="zh-cn"><head><meta charset="UTF-8"><title>最簡單的切換圖</title><!--兼容IE6+兼容火狐兼容谷歌兼容歐朋--></head><body><style>*{ margin:0; padding:0;}.banner{ width:200px; margin:40px auto 0 auto;}</style><div class="banner"><img src="img/a1.jpg" width="200" height="200" id="banner"></div><script src="jquery-1.7.2.min.js"></script><script>var imgIndex = 0;var arr = ['a1.jpg', 'a2.jpg', 'a3.jpg'];setInterval(imgChange, 4000);function imgChange() {imgIndex == (arr.length - 1) ? imgIndex = 0 : imgIndex += 1;$("#banner").attr('src','img/' + arr[imgIndex]);}</script></body></html>運(yùn)行效果圖如下:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注