微件:轮播图:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的4个中间版本) | |||
第1行: | 第1行: | ||
<includeonly> | <includeonly> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
const images=[ | const images=[ | ||
{ | { | ||
第12行: | 第11行: | ||
} | } | ||
] | ] | ||
document.addEventListener("DOMContentLoaded", function () { | |||
createSlider(images) | createSlider(images) | ||
}); | }); | ||
第23行: | 第23行: | ||
img.src = obj.src; | img.src = obj.src; | ||
img.style.opacity = index === 0 ? 1 : 0; | img.style.opacity = index === 0 ? 1 : 0; | ||
img.style.pointerEvents = index === 0 ? 'auto' : 'none'; | |||
img.onclick = () => window.open(obj.link, '_blank'); | img.onclick = () => window.open(obj.link, '_blank'); | ||
slider.appendChild(img); | slider.appendChild(img); | ||
第33行: | 第34行: | ||
dotsContainer.children[0].classList.add('active'); | dotsContainer.children[0].classList.add('active'); | ||
let sliderPrev = document.getElementById('sliderPrev'); | |||
let sliderNext = document.getElementById('sliderNext'); | |||
sliderPrev.onclick = () => prevSlide(); | |||
sliderNext .onclick = () => nextSlide(); | |||
setInterval(() => { | setInterval(() => { | ||
第41行: | 第47行: | ||
Array.from(slider.children).forEach((slide, index) => { | Array.from(slider.children).forEach((slide, index) => { | ||
slide.style.opacity = index === currentSlide ? 1 : 0; | slide.style.opacity = index === currentSlide ? 1 : 0; | ||
slide.style.pointerEvents = index === currentSlide ? 'auto' : 'none'; | |||
}); | }); | ||