首頁 > web前端 > js教程 > 主體

超漂亮的jQuery圖片輪播特效_jquery

WBOY
發布: 2016-05-16 15:30:09
原創
1107 人瀏覽過

超漂亮的jQuery圖片輪播特效,使用了插件jCarousel,很棒的jQuery插件,支援帶縮圖左右切換,支援Ajax加載數據,響應式佈局,支援行動觸控螢幕,強大的API參數配置功能以及函數回呼功能,支援自訂動畫速度和動畫模式,支援輪播方向定義,還是很不錯的,推薦學習和使用。

使用方法:
1.載入jQuery和外掛程式

<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內容

<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">&lsaquo;</a>
<a href="#" class="jcarousel-control-next">&rsaquo;</a>
<p class="jcarousel-pagination">
</p>
</div>
登入後複製

3.函數呼叫

 <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();
   });
 });
登入後複製

以上就是為大家推薦的jQuery圖片輪播特效的關鍵程式碼,大家還需要進一步的完善,可以結合之前的文章進行學習,一定會有意想不到的收穫。

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!