Home >Web Front-end >JS Tutorial >Super beautiful jQuery image carousel effect_jquery
Super beautiful jQuery image carousel effect, using the plug-in jCarousel, a great jQuery plug-in, supports left and right switching with thumbnails, supports Ajax loading data, responsive layout, supports mobile touch screens, and powerful API parameter configuration Function and function callback function, support custom animation speed and animation mode, support carousel direction definition, it is still very good, recommended to learn and use.
How to use:
1. Load jQuery and plug-ins
<link rel="stylesheet" type="text/css" href="jcarousel.basic.css"> <script type="text/javascript" src="libs/jquery/jquery.js"></script> <script type="text/javascript" src="dist/jquery.jcarousel.min.js"></script>
2.HTML content
<div class="jcarousel-wrapper"> <div class="jcarousel"> <ul> <li><img src="../_shared/img/img1.jpg" width="600" height="400" alt=""></li> <li><img src="../_shared/img/img2.jpg" width="600" height="400" alt=""></li> <li><img src="../_shared/img/img3.jpg" width="600" height="400" alt=""></li> <li><img src="../_shared/img/img4.jpg" width="600" height="400" alt=""></li> <li><img src="../_shared/img/img5.jpg" width="600" height="400" alt=""></li> <li><img src="../_shared/img/img6.jpg" width="600" height="400" alt=""></li> </ul> </div> <a href="#" class="jcarousel-control-prev">‹</a> <a href="#" class="jcarousel-control-next">›</a> <p class="jcarousel-pagination"> </p> </div>
3. Function call
<script type="text/javascript"> $(function(){ $('.jcarousel').jcarousel(); $('.jcarousel-control-prev') .on('jcarouselcontrol:active', function() { $(this).removeClass('inactive'); }) .on('jcarouselcontrol:inactive', function() { $(this).addClass('inactive'); }) .jcarouselControl({ target: '-=1' }); $('.jcarousel-control-next') .on('jcarouselcontrol:active', function() { $(this).removeClass('inactive'); }) .on('jcarouselcontrol:inactive', function() { $(this).addClass('inactive'); }) .jcarouselControl({ target: '+=1' }); $('.jcarousel-pagination') .on('jcarouselpagination:active', 'a', function() { $(this).addClass('active'); }) .on('jcarouselpagination:inactive', 'a', function() { $(this).removeClass('active'); }) .jcarouselPagination(); }); });
The above is the key code for the jQuery image carousel effect recommended for everyone. You still need to further improve it. You can combine it with the previous articles to learn, and you will definitely get unexpected gains.