jq實現(xiàn)左滑顯示刪除按鈕,點擊刪除實現(xiàn)刪除數(shù)據(jù)功能(推薦)
更新時間:2016年08月23日 11:40:05 投稿:jingxian
下面小編就為大家?guī)硪黄猨q實現(xiàn)左滑顯示刪除按鈕,點擊刪除實現(xiàn)刪除數(shù)據(jù)功能(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
效果圖
第一步:加載
<script src="js/jquery.min.js"></script> <script src="js/jquery.mobile-1.3.2.min.js"></script>
第二步:html
<div class="item-wrap"> <div class="item clearfix"> <div class="img-item"> <img src="images/icon.png"> </div> <div class="txt-item"> <p class="name"> 小黃人 </p> <p class="txt"> 小黃人小黃人小黃人小黃人 </p> </div> <i class="arrow"></i> <a class="delect-btn">刪除</a> </div> <div class="item clearfix"> <div class="img-item"> <img src="images/icon.png"> </div> <div class="txt-item"> <p class="name"> 小黃人 </p> <p class="txt"> 小黃人小黃人小黃人小黃人 </p> </div> <i class="arrow"></i> <a class="delect-btn">刪除</a> </div> </div>
第二步:css
.item-wrap{ overflow: hidden; } .item-wrap .item{ border-bottom: 1px #fff solid; background: #000; width: 125%; overflow: hidden; position: relative; display: -webkit-box; -webkit-transition: all 0.3s linear; } .item-wrap .item .img-item{ width: 50px; height: 50px; margin: 10px; } .item-wrap .item .img-item img{ width: 100%; border-radius: 50%; } .item-wrap .item .txt-item{ padding-top: 10px; margin-right:25px; font-size: 14px; line-height: 24px; color: #fff; -webkit-box-flex:1; } .item-wrap .item .arrow{ width: 0; height: 0; line-height: 0; font-size: 0; border-style: solid; border-color: transparent transparent transparent #fff; border-width: 8px 0px 8px 8px; position: absolute; right: 22%; top: 50%; margin-top: -8px; } .delect-btn{ width: 20%; margin-left: 15px; color: #fff; background: #0f0; z-index:999; display: block; text-align: center; padding-top: 5%; } .item-wrap .selected{ -webkit-transform: translate(-16%); -webkit-transition: all 0.3s linear; }
第二步:jq
<script> $(".item").on('swipeleft', function(event) { event.preventDefault(); /* Act on the event */ $(this).addClass('selected').siblings('.item').removeClass('selected'); $(this).find('.delect-btn').on('click', function(event) { event.preventDefault(); /* Act on the event */ $(this).parent(".item").animate({ height: 0, width: 0}, 300, function() { /* stuff to do after animation is complete */ $(this).remove(); }); }); }); $(".item").on('swiperight', function(event) { event.preventDefault(); /* Act on the event */ $(this).removeClass('selected'); }); </script>
以上這篇jq實現(xiàn)左滑顯示刪除按鈕,點擊刪除實現(xiàn)刪除數(shù)據(jù)功能(推薦)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- jQuery根據(jù)元素值刪除數(shù)組元素的方法
- jquery操作對象數(shù)組元素方法詳解
- jQuery教程 $()包裝函數(shù)來實現(xiàn)數(shù)組元素分頁效果
- jquery 動態(tài)增加刪除行的簡單實例(推薦)
- jquery刪除table當前行的實例代碼
- jQuery刪除節(jié)點用法示例(remove方法)
- jQuery增加、刪除及修改select option的方法
- jQuery 獲取頁面li數(shù)組并刪除不在數(shù)組中的key
- 基于jQuery實現(xiàn)表格的查看修改刪除
- jQuery實現(xiàn)表格行和列的動態(tài)添加與刪除方法【測試可用】
- jquery刪除數(shù)組中重復元素
相關文章
使用jQuery將多條數(shù)據(jù)插入模態(tài)框的實現(xiàn)代碼
這篇文章主要介紹了使用jQuery將多條數(shù)據(jù)插入模態(tài)框的方法,很簡單,很實用,需要的朋友可以參考下2014-10-10Jquery EasyUI實現(xiàn)treegrid上顯示checkbox并取選定值的方法
這篇文章主要介紹了Jquery EasyUI實現(xiàn)treegrid上顯示checkbox并取選定值的方法的相關資料,需要的朋友可以參考下2016-04-04jQuery實現(xiàn)contains方法不區(qū)分大小寫的方法
這篇文章主要介紹了jQuery實現(xiàn)contains方法不區(qū)分大小寫的方法,實例分析了針對contains方法的重寫技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-02-02