为块级元素添加tap跳转事件处理 --code reviewed by bikai
Showing
3 changed files
with
10 additions
and
9 deletions
@@ -9,7 +9,7 @@ var $ = require('jquery'), | @@ -9,7 +9,7 @@ var $ = require('jquery'), | ||
9 | 9 | ||
10 | var commentsNum,consultsNum; | 10 | var commentsNum,consultsNum; |
11 | 11 | ||
12 | -var consultFooterEle = document.getElementById('consult-content-footer'), | 12 | +var consultFooterEle = $('.consult-content-footer')[0], |
13 | consultFooterHammer = consultFooterEle && new Hammer(consultFooterEle), | 13 | consultFooterHammer = consultFooterEle && new Hammer(consultFooterEle), |
14 | 14 | ||
15 | navtabEle = document.getElementById('nav-tab'), | 15 | navtabEle = document.getElementById('nav-tab'), |
@@ -68,13 +68,13 @@ if (navtabHammer) { | @@ -68,13 +68,13 @@ if (navtabHammer) { | ||
68 | 68 | ||
69 | if (consultFooterHammer) { | 69 | if (consultFooterHammer) { |
70 | consultFooterHammer.on('tap', function() { | 70 | consultFooterHammer.on('tap', function() { |
71 | - location.href = $(consultFooterEle).find('a').attr('href'); | 71 | + location.href = $(consultFooterEle).data('href'); |
72 | }); | 72 | }); |
73 | } | 73 | } |
74 | 74 | ||
75 | if (gotoConsultHammer) { | 75 | if (gotoConsultHammer) { |
76 | gotoConsultHammer.on('tap', function() { | 76 | gotoConsultHammer.on('tap', function() { |
77 | - location.href = $(gotoConsultEle).find('a').attr('href'); | 77 | + location.href = $(gotoConsultEle).data('href'); |
78 | }); | 78 | }); |
79 | } | 79 | } |
80 | 80 |
1 | {{> layout/header}} | 1 | {{> layout/header}} |
2 | <div class="goods-consults-page yoho-page"> | 2 | <div class="goods-consults-page yoho-page"> |
3 | - <div class="goto-consult" id="goto-consult"> | 3 | + <div class="goto-consult" id="goto-consult" data-href="{{link}}"> |
4 | <i class="iconfont consult-logo"></i> | 4 | <i class="iconfont consult-logo"></i> |
5 | <span>我要咨询</span> | 5 | <span>我要咨询</span> |
6 | - <a href="{{link}}" class="iconfont enter-consult-page"></a> | 6 | + <a href="javascript:;" class="iconfont enter-consult-page"></a> |
7 | </div> | 7 | </div> |
8 | {{# consults}} | 8 | {{# consults}} |
9 | <div class="goods-consults" id="goods-consults"> | 9 | <div class="goods-consults" id="goods-consults"> |
@@ -49,8 +49,8 @@ | @@ -49,8 +49,8 @@ | ||
49 | </div> | 49 | </div> |
50 | {{/ consults}} | 50 | {{/ consults}} |
51 | </div> | 51 | </div> |
52 | - <div class="consult-content-footer" id="consult-content-footer"> | ||
53 | - <a href="{{link}}"> | 52 | + <div class="consult-content-footer" data-href="{{link}}"> |
53 | + <a href="javascript:;"> | ||
54 | 查看更多 | 54 | 查看更多 |
55 | <span class="iconfont"></span></a> | 55 | <span class="iconfont"></span></a> |
56 | </div> | 56 | </div> |
@@ -58,8 +58,9 @@ | @@ -58,8 +58,9 @@ | ||
58 | <div class="consult-content-main content-main no-item"> | 58 | <div class="consult-content-main content-main no-item"> |
59 | <span class="iconfont"></span>暂无咨询 | 59 | <span class="iconfont"></span>暂无咨询 |
60 | </div> | 60 | </div> |
61 | - <div class="consult-content-footer"> | ||
62 | - <a href="{{link}}"> | 61 | + |
62 | + <div class="consult-content-footer" data-href="{{link}}"> | ||
63 | + <a href="javascript:;"> | ||
63 | 我要咨询 | 64 | 我要咨询 |
64 | <span class="iconfont"></span></a> | 65 | <span class="iconfont"></span></a> |
65 | </div> | 66 | </div> |
-
Please register or login to post a comment