1. 先引入jquery.js,再引入switchPage.js
文件地址:点击打开链接
<script src="jquery.min.js"></script> <script src="switchPage.js"></script>
2. 书写html
<div id="container"> <div class="section active" style="background: red"></div> <div class="section" style="background: green"></div> <div class="section" style="background: yellow"></div> <div class="section" style="background: pink"></div> </div>
3. 设置对应的样式
<style> html,body{ height: 100%; overflow: hidden; } #container{ height: 100%; position: relative; } #container,.section{ height: 100%; position: relative; } </style>
4. 调用插件方法
$(function () { $('#container').switchPage({ 'loop':true, 'keyboard':true }) })