欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

JavaScript

當(dāng)前位置:主頁 > 網(wǎng)絡(luò)編程 > JavaScript >

JS實(shí)現(xiàn)圖片切換特效

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:JavaScript|點(diǎn)擊: 次

本文實(shí)例為大家分享了JS實(shí)現(xiàn)圖片切換的具體代碼,供大家參考,具體內(nèi)容如下

知識(shí)點(diǎn):

1.window.onload網(wǎng)頁全部加載完后再執(zhí)行
2.獲取元素 設(shè)置屬性
3.臨界情況判斷

運(yùn)行效果:

點(diǎn)擊上一張下一章切換圖片

代碼:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<style>
  #box{
    width: 1200px;
    margin: 0 auto;
  }
</style>
<body>
  <div id="box">
    <img id="icon" src="images/阿魯1.gif" alt="">
    <p></p>
    <button id="prep">上一張</button>
    <button id="next">下一張</button>
  </div>
<script>
  window.onload = function (ev) {
    // 1. 獲取標(biāo)簽
    var prep = document.getElementById('prep');
    var next = document.getElementById('next');
    var icon = document.getElementById('icon');
    // 2. 點(diǎn)擊
    var currentIndex = 1, minIndex=1, maxIndex=10;
    prep.onclick = function (ev1) {
      if (currentIndex === minIndex){
        currentIndex = maxIndex;
      }else{
        currentIndex--;
      }
      icon.setAttribute('src','images/阿魯'+ currentIndex +'.gif');
    };
    next.onclick = function (ev1) {
      if (currentIndex === maxIndex){
        currentIndex = minIndex;
      }else {
        currentIndex++;
      }
      icon.setAttribute('src','images/阿魯'+ currentIndex +'.gif');
    }
  }
</script>
</body>
</html>

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:Javascript實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊冒泡特效

欄    目:JavaScript

下一篇:Vue移動(dòng)端實(shí)現(xiàn)圖片上傳及超過1M壓縮上傳

本文標(biāo)題:JS實(shí)現(xiàn)圖片切換特效

本文地址:http://mengdiqiu.com.cn/a1/JavaScript/9410.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有