From dc39981851a438a7129388770dc535dbe18f3fba Mon Sep 17 00:00:00 2001 From: anyv <anyu@bronet.cn> Date: Tue, 4 Jun 2019 09:15:25 +0800 Subject: [PATCH] 1 --- public/themes/simpleboot3/portal/personalcenter/shop_address.html | 2 +- public/themes/simpleboot3/public/assets/js/address.js | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/public/themes/simpleboot3/portal/personalcenter/shop_address.html b/public/themes/simpleboot3/portal/personalcenter/shop_address.html index 2468901..a888d1c 100644 --- a/public/themes/simpleboot3/portal/personalcenter/shop_address.html +++ b/public/themes/simpleboot3/portal/personalcenter/shop_address.html @@ -26,7 +26,7 @@ <div class="ad_content"> <ul id="ad_contentUl"> <volist name="data" id="vo"> - <li onclick="fors()"> + <li ontouchstart="fors()"> <div class="ad_conBox"> <div class="ad_con1"> <p class="ad_conName">{$vo.name}</p> diff --git a/public/themes/simpleboot3/public/assets/js/address.js b/public/themes/simpleboot3/public/assets/js/address.js index 9bf11ec..6647893 100644 --- a/public/themes/simpleboot3/public/assets/js/address.js +++ b/public/themes/simpleboot3/public/assets/js/address.js @@ -1,5 +1,12 @@ // 删除默认 -document.addEventListener('DOMContentLoaded', function() { +const clickEvent = (function() { + if ('ontouchstart' in document.documentElement === true) + return 'touchstart'; + else + return 'click'; +})(); +clickEvent.addEventListener('DOMContentLoaded', function(ev) { + ev.preventDefault(); // var oUl = document.getElementsById('ad_contentUl')[0]; var oUl = document.querySelector('#ad_contentUl'); var aLi = oUl.querySelectorAll('li'); @@ -40,8 +47,8 @@ document.addEventListener('DOMContentLoaded', function() { }, false) // 删除按钮 aDel[i].index = i; - aDel[i].addEventListener('touchstart', function(e) { - e.preventDefault(); + aDel[i].addEventListener('touchstart', function(ev) { + ev.preventDefault(); this.innerHTML = ''; this.style.height = '0'; this.style.display = 'none'; @@ -50,14 +57,14 @@ document.addEventListener('DOMContentLoaded', function() { aDiv[this.index].style.height = '0'; aDiv[this.index].style.display = 'none'; aDiv[this.index].innerHTML = ''; - this.addEventListener('transitionend', function(e) { - e.preventDefault(); + this.addEventListener('transitionend', function(ev) { + ev.preventDefault(); oUl.removeChild(aLi[this.index]); }, false) }, false); aMo[i].index = i; - aMo[i].addEventListener('touchstart', function(e) { - e.preventDefault(); + aMo[i].addEventListener('touchstart', function(ev) { + ev.preventDefault(); // var adName = document.querySelectorAll('.ad_conMo'); $('.ad_conMo').eq(this.index).css('display', 'block').parents('li').siblings().find('.ad_conMo').css('display', 'none') -- libgit2 0.24.0