Thinkphp結合AJAX長輪詢實現PC與APP推送詳解
851
2023-12-08
效果圖
第一步:加載
<script src="http://www.gimoo.net/t/1901/js/jquery.min.js"></script> <script src="http://www.gimoo.net/t/1901/js/jquery.mobile-1.3.2.min.js"></script>
第二步:html
<div class="item-wrap"> <div class="item clearfix"> <div class="img-item"> <img src="http://www.gimoo.net/t/1901/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="http://www.gimoo.net/t/1901/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實現左滑顯示刪除按鈕,點擊刪除實現刪除數據功能(推薦)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持綠夏網。
#免責聲明#
本站[綠夏技術導航]提供的一切軟件、教程和內容信息僅限用于學習和研究目的;不得將上述內容用于商業或者非法用途,否則,一切后果請用戶自負。本站信息來自網絡收集整理,版權爭議與本站無關。您必須在下載后的24個小時之內,從您的電腦或手機中徹底刪除上述內容。如果您喜歡該程序或內容,請支持正版,購買注冊,得到更好的正版服務。我們非常重視版權問題,如有侵權請郵件[admin@lxwl520.com]與我們聯系進行刪除處理。敬請諒解!