JQ长按事件,且对未来元素操作


 1 var timeOutEvent = 0;
 2 $("#order_list").delegate(".renewalList","touchstart",function(e){
 3   var that = $(this);
 4   longClick=0;//设置初始为0
 5   currIndex = that.data("value");
 6   // console.log(currIndex);
 7   // 将当前元素的索引作为参数进行传递
 8   timeOutEvent = setTimeout(function () {
 9     longClick=1;//假如长按,则设置为1
10     $(".delete_popup").show();
11   }, 1000);
12 })
13 $("#order_list").delegate(".renewalList","touchmove",function(e){
14   clearTimeout(timeOutEvent);
15   timeOutEvent = 0;
16   //e.preventDefault();
17 })
18 $("#order_list").delegate(".renewalList","touchend",function(e){
19   var that = $(this);
20 /*  console.log(that.data("value"));*/
21   currIndex = that.data("value");
22   clearTimeout(timeOutEvent);
23   if(timeOutEvent!=0 && longClick==0) {
24     window.location.href = "searchDetails.html?id=" + currIndex + "&renewalId="+currIndex;
25   } /*else {
26     $(".delete_popup").show();
27   }*/
28   timeOutEvent==0;
29   return false;
30 })

 

 

 

posted @ 2020-07-23 15:57  sunzy_blog  阅读(251)  评论(0)    收藏  举报