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ù)功能(推薦)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- jQuery根據(jù)元素值刪除數(shù)組元素的方法
- jquery操作對(duì)象數(shù)組元素方法詳解
- jQuery教程 $()包裝函數(shù)來(lái)實(shí)現(xiàn)數(shù)組元素分頁(yè)效果
- jquery 動(dòng)態(tài)增加刪除行的簡(jiǎn)單實(shí)例(推薦)
- jquery刪除table當(dāng)前行的實(shí)例代碼
- jQuery刪除節(jié)點(diǎn)用法示例(remove方法)
- jQuery增加、刪除及修改select option的方法
- jQuery 獲取頁(yè)面li數(shù)組并刪除不在數(shù)組中的key
- 基于jQuery實(shí)現(xiàn)表格的查看修改刪除
- jQuery實(shí)現(xiàn)表格行和列的動(dòng)態(tài)添加與刪除方法【測(cè)試可用】
- jquery刪除數(shù)組中重復(fù)元素
相關(guān)文章
z-blog SyntaxHighlighter 長(zhǎng)代碼無(wú)法換行解決辦法(jquery)
由于我的博客主要是代碼分享,很多貼的代碼,都很長(zhǎng)。很多時(shí)候我都是手動(dòng)給他換行。但是今天實(shí)在是受不了。從網(wǎng)上找個(gè)辦法解決一下2014-11-11
為什么要在引入的css或者js文件后面加參數(shù)的詳細(xì)講解
為什么要在引入的css或者js文件后面加參數(shù)的詳細(xì)講解,需要的朋友可以參考一下2013-05-05
jQuery頁(yè)面元素動(dòng)態(tài)添加后綁定事件丟失方法,非 live
這篇文章主要介紹了jQuery頁(yè)面元素動(dòng)態(tài)添加后綁定事件丟失方法,非 live 的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)吧2016-06-06
getJSON調(diào)用后臺(tái)json數(shù)據(jù)時(shí)函數(shù)被調(diào)用兩次的原因猜想
近期在做前端開發(fā)時(shí)候使用到getJSON調(diào)用后臺(tái)json數(shù)據(jù),發(fā)現(xiàn)后臺(tái)的函數(shù)被調(diào)用兩次,函數(shù)名稱為getMessages,下面是本人的一些猜想,感興趣的朋友可以參考下2013-09-09
JQuery CheckBox(復(fù)選框)操作方法匯總
這篇文章主要介紹了JQuery CheckBox(復(fù)選框)操作方法匯總,本文講解了獲取單個(gè)checkbox選中項(xiàng)、獲取多個(gè)checkbox選中項(xiàng)、設(shè)置第一個(gè)checkbox 為選中值、設(shè)置最后一個(gè)checkbox為選中值等內(nèi)容,需要的朋友可以參考下2015-04-04

