jquery和swiper组件实现年份时间轴滑动效果

【jquery和swiper组件实现年份时间轴滑动效果】需要用到的组件:Swiper中文网-轮播图幻灯片js插件,H5页面前端开发
html代码:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title></title><script src="js/jquery-3.4.1.min.js"></script><script src="js/swiper-4.5.3/js/swiper.min.js"></script><link rel="stylesheet" href="js/swiper-4.5.3/css/swiper.min.css" rel="external nofollow" ><link rel="stylesheet" href="css/style.css"></head><body><div class="swiper-container box"><div class="swiper-wrApper main-timeline"><div class="swiper-slide timeline fd-active-line"><a href="JAVAscript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2022</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="JavaScript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2021</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2020</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2019</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2018</span></div></a><div class="show_timeline"></div></div><div class="swiper-slide timeline"><a href="javascript:void(0);" rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="timeline-content"><div class="timeline-year"><span>2017</span></div></a><div class="show_timeline"></div></div></div></div><ul class="event_list"><div><h3 id="2022">2022</h3><img src="images/sl01.PNG" alt=""></div><div style="display: none;"><h3 id="2021">2021</h3><img src="images/sl02.PNG" alt=""></div><div style="display: none;"><h3 id="2020">2020</h3><img src="images/sl03.PNG" alt=""></div><div style="display: none;"><h3 id="2019">2019</h3><img src="images/sl04.PNG" alt=""></div><div style="display: none;"><h3 id="2018">2018</h3><img src="images/sl05.PNG" alt=""></div><div style="display: none;"><h3 id="2017">2017</h3><img src="images/sl06.PNG" alt=""></div></ul></div><script>$(function () {$(".main-timeline .timeline").click(function () {var target = $(this).siblings().length;if (target >= 1) {var index = $(this).index()$(this).addClass('fd-active-line').siblings().removeClass('fd-active-line')$(this).parent().parent().siblings('.event_list').children().eq(index).show().siblings().hide()}})var swiper = new Swiper('.swiper-container', {slidesPerView: 4,direction: 'vertical',navigation: {nextEl: '.swiper-button-next',prevEl: '.swiper-button-prev',},on: {resize: function () {swiper.changeDirection(getDirection());}}});});</script></body></html>


推荐阅读