jq實(shí)現(xiàn)左滑顯示刪除按鈕,點(diǎn)擊刪除實(shí)現(xiàn)刪除數(shù)據(jù)功能(推薦)
效果圖
第一步:加載
<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實(shí)現(xiàn)左滑顯示刪除按鈕,點(diǎn)擊刪除實(shí)現(xiàn)刪除數(shù)據(jù)功能(推薦)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
- jQuery根據(jù)元素值刪除數(shù)組元素的方法
- jquery操作對象數(shù)組元素方法詳解
- jQuery教程 $()包裝函數(shù)來實(shí)現(xiàn)數(shù)組元素分頁效果
- jquery 動態(tài)增加刪除行的簡單實(shí)例(推薦)
- jquery刪除table當(dāng)前行的實(shí)例代碼
- jQuery刪除節(jié)點(diǎn)用法示例(remove方法)
- jQuery增加、刪除及修改select option的方法
- jQuery 獲取頁面li數(shù)組并刪除不在數(shù)組中的key
- 基于jQuery實(shí)現(xiàn)表格的查看修改刪除
- jQuery實(shí)現(xiàn)表格行和列的動態(tài)添加與刪除方法【測試可用】
- jquery刪除數(shù)組中重復(fù)元素
相關(guān)文章
jquery tools 系列 scrollable學(xué)習(xí)
今天繼續(xù)jquery tools六大功能之第三功能 scrollable的學(xué)習(xí)。一如既往,首先給出操作的html代碼 此html代碼修改自jquery tools官方網(wǎng)站demo代碼2009-09-09jQuery根據(jù)name屬性進(jìn)行查找的用法分析
這篇文章主要介紹了jQuery根據(jù)name屬性進(jìn)行查找的用法,結(jié)合實(shí)例形式分析了jQuery各種常見name屬性獲取元素的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-06-06Jquery增加鼠標(biāo)中間功能mousewheel的實(shí)例代碼
這篇文章介紹了Jquery增加鼠標(biāo)中間功能mousewheel的實(shí)例代碼,有需要的朋友可以參考一下2013-09-09jQuery實(shí)現(xiàn)tab標(biāo)簽自動切換的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)tab標(biāo)簽自動切換的方法,實(shí)例分析了jQuery操作tab標(biāo)簽的技巧,涉及addClass、siblings及removeClass鏈?zhǔn)讲僮鞯募记?需要的朋友可以參考下2015-02-02使用jQuery將多條數(shù)據(jù)插入模態(tài)框的實(shí)現(xiàn)代碼
這篇文章主要介紹了使用jQuery將多條數(shù)據(jù)插入模態(tài)框的方法,很簡單,很實(shí)用,需要的朋友可以參考下2014-10-10Jquery EasyUI實(shí)現(xiàn)treegrid上顯示checkbox并取選定值的方法
這篇文章主要介紹了Jquery EasyUI實(shí)現(xiàn)treegrid上顯示checkbox并取選定值的方法的相關(guān)資料,需要的朋友可以參考下2016-04-04基于JQuery實(shí)現(xiàn)圖片輪播效果(焦點(diǎn)圖)
這篇文章主要為大家詳細(xì)介紹了基于JQuery實(shí)現(xiàn)圖片輪播效果,利用Jquery制作焦點(diǎn)圖左右輪播特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-02-02jQuery實(shí)現(xiàn)contains方法不區(qū)分大小寫的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)contains方法不區(qū)分大小寫的方法,實(shí)例分析了針對contains方法的重寫技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-02-02