jQuery图片文本滚动切换插件jCarousel

                                                                               jCarousel 

jCarousel 是个非常好看又好用的内容滚动切换插件,可以实现按序水平或垂直,可以实现如新浪微博首页效果, 


Java代码   收藏代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">  
  4. <head>  
  5. <title>jCarousel Examples</title>  
  6. <link href="../style.css" rel="stylesheet" type="text/css" />  
  7.   
  8. <!--  
  9.   jQuery library  
  10. -->  
  11. <script type="text/javascript" src="../lib/jquery-1.4.2.min.js"></script>  
  12.   
  13. <!--  
  14.   jCarousel library  
  15. -->  
  16. <script type="text/javascript" src="../lib/jquery.jcarousel.min.js"></script>  
  17.   
  18. <!--  
  19.   jCarousel skin stylesheet  
  20. -->  
  21. <link rel="stylesheet" type="text/css" href="../skins/ie7/skin.css" />  
  22.   
  23. <script type="text/javascript">  
  24.   
  25. function mycarousel_itemLoadCallback(carousel, state)  
  26. {  
  27.     // Since we get all URLs in one file, we simply add all items  
  28.     // at once and set the size accordingly.  
  29.     if (state != 'init')  
  30.         return;  
  31.   
  32.     jQuery.get('dynamic_ajax.txt', function(data) {  
  33.         mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);  
  34.     });  
  35. };  
  36.   
  37. function mycarousel_itemAddCallback(carousel, first, last, data)  
  38. {  
  39.     // Simply add all items at once and set the size accordingly.  
  40.     var items = data.split('|');  
  41.   
  42.     for (i = 0; i < items.length; i++) {  
  43.         carousel.add(i+1, mycarousel_getItemHTML(items[i]));  
  44.     }  
  45.   
  46.     carousel.size(items.length);  
  47. };  
  48.   
  49. /** 
  50.  * Item html creation helper. 
  51.  */  
  52. function mycarousel_getItemHTML(url)  
  53. {  
  54.     return '<img src="' + url + '" width="75" height="75" alt="" />';  
  55. };  
  56.   
  57. jQuery(document).ready(function() {  
  58.     jQuery('#mycarousel').jcarousel({  
  59.         itemLoadCallback: mycarousel_itemLoadCallback  
  60.     });  
  61. });  
  62.   
  63. </script>  
  64. </head>  
  65. <body>  
  66. <div id="wrap">  
  67.   <h1>jCarousel</h1>  
  68.   <h2>Riding carousels with jQuery</h2>  
  69.   
  70.   <h3>Carousel with dynamic content loading via Ajax</h3>  
  71.   <p>  
  72.     The data is loaded dynamically from a simple text file which contains the image urls.  
  73.   </p>  
  74.   
  75.   <div id="mycarousel" class="jcarousel-skin-ie7">  
  76.     <ul>  
  77.       <!-- The content will be dynamically loaded in here -->  
  78.     </ul>  
  79.   </div>  
  80.   
  81. </div>  
  82. </body>  
  83. </html>  

效果如下: 
 
更多例子请参考 
https://github.com/jsor/jcarousel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值