我在div上已向左滑动
$(".iframe-content").swipeleft(function(e) {
alert ("test 1");
});
<div class="iframe-content">
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div id="another-swipe">swipe here</div>
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div><div class="noswipe">no swipe</div>
</div>
现在我的问题正好是:
在iframe-content上滑动可正常工作,但我在
another-swipe
上再次滑动$(".another-swipe").swipeleft(function(e) {
alert("test2")
});
但它给出的前一个警报不是
alert("test2");
...。 最佳答案
使用class而不是ID进行另一次刷卡。
您可以使用e.stopPropagation();停止高呼
在此处查看小提琴(单击而不是滑动):http://jsfiddle.net/26w2q/
的HTML
<div class="iframe-content">
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div class="another-swipe">swipe here</div> <<< USE class instead of id
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
<div class="noswipe">no swipe</div>
</div>
JQUERY
$(".another-swipe").swipeleft(function(e) {
e.stopPropagation();
alert("test2")
});
$(".iframe-content").swipeleft(function(e) {
alert ("test 1");
});
关于javascript - 同一页面中的多个交换不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19784442/