Home >Web Front-end >JS Tutorial >Basic use of swiper (13)
In this content, we introduce adding control buttons to the swiper page (which can control turning to the previous page and next page).
First build the basic swiper page layout. Then we mainly add the div of the page turning button (.swiper-button-next/prev) to the external container (.swiper-container).
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide">H5EDU 1<img src="logo.png"></div> <div class="swiper-slide">H5EDU 2<img src="logo.png"></div> <div class="swiper-slide">H5EDU 3<img src="logo.png"></div> <div class="swiper-slide">H5EDU 4<img src="logo.png"></div> <div class="swiper-slide">H5EDU 5<img src="logo.png"></div> <div class="swiper-slide">H5EDU 6<img src="logo.png"></div> </div> <div class="swiper-pagination"></div> <div class="swiper-button-next"></div> <div class="swiper-button-prev"></div> </div>
Then go to the js part to initialize the function and bind the page turning button the type.
var swiper = new Swiper('.swiper-container',{ pagination:'.swiper-pagination', paginationClickable:true, spaceBetween:30, nextButton:'.swiper-button-next',//绑定下一页的控制按钮 prevButton:'.swiper-button-prev'//绑定上一页的控制按钮 });
We can change the color of the control button through the class name. And the control buttons will change to the corresponding style or add functions as our attributes change
The above is the content of the basic use of swiper (13). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!