我已经实现了一个下拉分享按钮,如Here所示,它可以工作,但它在每一篇帖子之后都能工作。我想知道为什么它在每一篇帖子之后都能工作。我能错过什么呢?
Javascript:
<script>
$('.social-toggle').on('click', function() {
$(this).next().toggleClass('open-menu');
});
</script>我的Html:
<a href="javascript:void(0);" class="social-toggle">
<i class="fa fa-share-alt" aria-hidden="true"> Share This</i></a>
<div class="social-networks">
<ul>
<li class="social-twitter">
<a href="https://twitter.com/share?url={{STORY}}&text={{TEXT}}&via=Yaye" alt="Tweet this" target="_blank" rel="nofollow"><i class="fa fa-twitter" aria-hidden="true"></i></a>
</li>
<li class="social-facebook">
<a href="http://www.facebook.com/sharer.php?u={{STORY}}&title={{TEXT}}" alt="Share on Facebook" target="_blank" rel="nofollow"><i class="fa fa-facebook-square" aria-hidden="true"></i></a>
</li>
<li class="social-whatsapp">
<a href="whatsapp://send?text={{TEXT}}{{STORY}}" target="_blank" rel="nofollow"><i class="fa fa-whatsapp" aria-hidden="true"></i></a>
</li>
<li class="social-telegram">
<a href="whatsapp://send?text={{TEXT}}{{STORY}}" target="_blank" rel="nofollow"><i </a>
</li>
</ul>
</div>发布于 2017-12-29 20:56:11
我使用e.preventDefault();禁用了此行为,如下所示。现在它可以按要求工作了。
script>
$('.social-toggle').on('click', function() {
$(this).next().toggleClass('open-menu');
e.preventDefault();
});
</script> https://stackoverflow.com/questions/47909042
复制相似问题