jQuery UI 实现 仿购物车功能 简洁的js .

  1. <span style="font-size:18px;">效果图</span>  
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  5. <title>无标题文档</title>  
  6. <!-- 引入js类库 -->  
  7. <script language="javascript" src="js/jquery-1.7.1.min.js" type="text/javascript"></script>  
  8. <script language="javascript" src="js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>  
  9. <!-- 引入css类库 -->  
  10. <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.18.custom.css" />  
  11. <script type="text/javascript" language="javascript">  
  12. $(function (){  
  13. $("#catalog").accordion();  //手风琴效果  
  14.     $("#products li").draggable({   //添加拖拽效果  
  15.         connectToSortable:"#ui-widget-content ol",   //向ol中添加元素  
  16.         appendTo:"body",    //追加到body中  
  17.          helper:"clone",   //克隆  
  18.          revert:true      //是否返回原来的地方  
  19.         });  
  20.           
  21.     $("#ui-widget-content ol").sortable({  
  22.         sort:function(event,ui){    //触发事件  
  23.             $(this).find("#placeholder").remove();  //触发事件时进行删除  
  24.             }  
  25.         });  
  26.      });  
  27.     </script>  
  28.   <style>  
  29.     h1 { padding: .2em; margin: 0; }  
  30.     #products { float:left; width: 500px; margin-right: 2em; }  
  31.     #cart { width: 200px; float: left; }  
  32.     /* style the list to maximize the droppable hitarea */  
  33.     #cart ol { margin: 0; padding: 1em 0 1em 3em; }  
  34.     </style>    
  35.       
  36. </head>  
  37.   
  38. <body>  
  39. <div class="demo">  
  40.       
  41. <div id="products">  
  42.     <h1 class="ui-widget-header">Products</h1>    
  43.     <div id="catalog">  
  44.         <h3><a href="#">T-Shirts</a></h3>  
  45.   
  46.         <div>  
  47.             <ul>  
  48.                 <li>Lolcat Shirt</li>  
  49.                 <li>Cheezeburger Shirt</li>  
  50.                 <li>Buckit Shirt</li>  
  51.             </ul>  
  52.         </div>  
  53.   
  54.         <h3><a href="#">Bags</a></h3>  
  55.         <div>  
  56.             <ul>  
  57.                 <li>Zebra Striped</li>  
  58.                 <li>Black Leather</li>  
  59.                 <li>Alligator Leather</li>  
  60.             </ul>  
  61.   
  62.         </div>  
  63.         <h3><a href="#">Gadgets</a></h3>  
  64.         <div>  
  65.             <ul>  
  66.                 <li>iPhone</li>  
  67.                 <li>iPod</li>  
  68.                 <li>iPad</li>  
  69.   
  70.             </ul>  
  71.         </div>  
  72.     </div>  
  73. </div>  
  74.   
  75. <div id="cart" >  
  76.     <h1 class="ui-widget-header">Shopping Cart</h1>  
  77.     <div id="ui-widget-content">  
  78.         <ol>  <!--ol 表示有序列表 -->  
  79.             <li class="placeholder" id="placeholder">Add your items here</li>  
  80.         </ol>  
  81.     </div>  
  82. </div>  
  83.   
  84. </div><!-- End demo -->  
  85.   
  86.   
  87.   
  88.    
  89.   
  90. </body>  
  91. </html>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值