快速生成一个 Slider 组件
- jQuery 1.12+
- IE 9+
give the slider component an id, here is slider-demo
<div class="slider" id="slider-demo">
<div class="slide-viewer">
<ul class="slide-group">
<li class="slide">
<a href="#"><img src="img/img1.jpg" alt="img1"></a>
</li>
<li class="slide">
<a href="#"><img src="img/img2.jpg" alt="img2"></a>
</li>
<li class="slide">
<a href="#"><img src="img/img3.jpg" alt="img3"></a>
</li>
<li class="slide">
<a href="#"><img src="img/img4.jpg" alt="img4"></a>
</li>
</ul>
</div>
<div class="slide-btn slide-btn-prev"><</div>
<div class="slide-btn slide-btn-next">></div>
<div class="slide-bullets"></div>
</div>
insert CSS file in the head
<link rel="stylesheet" href="css/Slider.css">
Insert Javascript file
<script src="js/Slider.js"></script>
And then initialize the slider using it's id
Slider.init('#slider-demo');