我正在使用jquery.touchSwipe插件,但我现在面临着一个问题。
如果div中有任何链接,当您尝试打开该链接时,它将不起作用,但当您滑动它时,它将正常工作。
检查下面的代码。
$(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
});
});.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;
}<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>
发布于 2016-11-26 21:06:58
为了能够点击/点击链接,也能够滑动菜单,你需要使用大约75的卷帘-treshold(而不是零!)并确保没有排除"A“元素,否则您可以休息排除列表。
$(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: ""
});
});https://stackoverflow.com/questions/40818423
复制相似问题