首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >链接的jquery.touchSwipe问题

链接的jquery.touchSwipe问题
EN

Stack Overflow用户
提问于 2016-11-26 20:42:35
回答 1查看 1.1K关注 0票数 0

我正在使用jquery.touchSwipe插件,但我现在面临着一个问题。

如果div中有任何链接,当您尝试打开该链接时,它将不起作用,但当您滑动它时,它将正常工作。

检查下面的代码。

代码语言:javascript
复制
$(function() {			
					//Enable swiping...
					$("#test").swipe( {
						//Generic swipe handler for all directions
						swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
							$(this).html("You swiped " + direction+"<br><a href='http://www.google.com/'>google.com</a>" );	
						},
						//Default is 75px, set to 0 for demo so any distance triggers swipe
					   threshold:0
					});
				});
代码语言:javascript
复制
.box
{
	margin-top:20px;
	margin-bottom:20px;
	max-width:768px;
	height:300px;
	
	padding: 10px;
	background-color: #EEE;
	-webkit-border-radius: 6px;
	-moz-border-radius: 6px;
	border-radius: 6px;
	
	text-align:center;
	font-weight: 300;
	font-size: 20px;
	line-height: 36px;
	
	overflow:hidden;
}
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://m.couponi.com.sa/jquery.touchSwipe.js"></script>

<div id="test" class="box">Swipe me
            
            
            <a href="http://www.google.com/">google.com</a>
            
            
            
            </div>

EN

回答 1

Stack Overflow用户

发布于 2016-11-26 21:06:58

为了能够点击/点击链接,也能够滑动菜单,你需要使用大约75的卷帘-treshold(而不是零!)并确保没有排除"A“元素,否则您可以休息排除列表。

代码语言:javascript
复制
$(function() {          
                //Enable swiping...
                $("#test").swipe( {
                    //Generic swipe handler for all directions
                    swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
                        $(this).html("You swiped " + direction+"<br><a href='http://www.google.com/'>google.com</a>" ); 
                    },
                    //Default is 75px, set to 0 for demo so any distance triggers swipe
    threshold: 75,
    excludedElements: ""
                });
            });
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40818423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档