首页 > 代码库 > zepto小功能汇总

zepto小功能汇总

1.长按删除功能

 1 i.remove 2 { 3     display:none; 4     float:right; 5     height: 20px; 6     padding-right: 10px; 7     width: 9px; 8     background: url(/setshop/images/del_1.png) center no-repeat; 9 }10 11 1213 <div class="skills">14             <ul>15                 <li>logo设计<i class="remove"></i></li>16                 <li>VI设计<i class="remove"></i></li>17                 <li>宣传页设计<i class="remove"></i></li>18                 <li>UI设计<i class="remove"></i></li>19                 <li>网页设计<i class="remove"></i></li>20                 <li>界面设计<i class="remove"></i></li>21             </ul>22             <div class="clear"></div>23         </div>
 1 <script type="text/javascript"> 2     /* 长按删除  */ 3     $.fn.longPress = function (fn) { 4         var timeout = undefined; 5         var $this = this; 6         for (var i = 0; i < $this.length; i++) { 7             $this[i].addEventListener(touchstart, function (event) { 8                 timeout = setTimeout(function (e) { 9                     $(.skills ul li i.remove).toggle();10                 }, 800);  /*长按时间超过800ms,则执行传入的方法*/  11             }, false);12             $this[i].addEventListener(touchend, function (event) {13                 clearTimeout(timeout);  /*长按时间少于800ms,不会执行传入的方法*/  14             }, false);15         }16     }17     $(.skills ul li).longPress(function (e) {18     });19 20     $(i.remove).on(touchend, function () {21         $(this).parent().remove();22     }) 23 24 </script>

 

zepto小功能汇总