我想使用以下代码来实现最小宽度为720px且小于720px的代码,我只想显示slideIndex-1,slideIndex,slideIndex + 1,告诉我如何在以下代码中使用windowsMatchmedia?
这是脚本
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides1(n) {
showSlides(slideIndex += n+4);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for(i=0;i<slides.length;i++){
var NewSlides2=[slideIndex-1,slideIndex,slideIndex+1,slideIndex+2,slideIndex+3];
for (k=0; k<5; k++)
slides[NewSlides2[k]].style.display = "inline-block";
}
</script>