从链接中删除单击事件并恢复默认行为

时间:2014-07-05 20:22:37

标签: javascript jquery html

我正在使用一组图片来使用插件构建图库。我想添加一个最后一组作为点击更多链接,如下所示。

enter image description here

<div id="lightGallery" class="row no-gutter venue-photo-list" data-rel="venue-photos">
                  <div class="col-xs-4 col-md-2" data-title="Nomad" data-desc="Travel the World like a Nomad" data-src="images/venues/venue-medium.jpg"> <a href="javascript:void(0)"> <img src="images/venues/venue-medium.jpg" alt=""> </a> </div>
                  <div class="col-xs-4 col-md-2" data-title="Nomad" data-desc="Travel the World like a Nomad" data-src="images/venues/venue-medium6.jpg"> <a href="javascript:void(0)"> <img src="images/venues/venue-medium6.jpg" alt=""> </a> </div>
                  <div class="col-xs-4 col-md-2" data-title="Nomad" data-desc="Travel the World like a Nomad" data-src="images/venues/venue-medium2.jpg"> <a href="javascript:void(0)"> <img src="images/venues/venue-medium2.jpg" alt=""> </a> </div>
                  <div class="col-xs-4 col-md-2" data-title="Nomad" data-desc="Travel the World like a Nomad" data-src="images/venues/venue-medium3.jpg"> <a href="javascript:void(0)"> <img src="images/venues/venue-medium3.jpg" alt=""> </a> </div>
                  <div class="col-xs-4 col-md-2" data-title="Nomad" data-desc="Travel the World like a Nomad" data-src="images/venues/venue-medium4.jpg"> <a href="javascript:void(0)"> <img src="images/venues/venue-medium4.jpg" alt=""> </a> </div>
                  <div class="col-xs-4 col-md-2" data-title="Nomad" data-desc="Travel the World like a Nomad" data-src="images/venues/venue-medium5.jpg"> <a href="javascript:void(0)"> <img src="images/venues/venue-medium5.jpg" alt=""> </a> </div>
                  <div class="col-xs-4 col-md-2 more-photos"> <a href="http://google.com">More</a> </div>
                </div>

当我点击该按钮时,我想重定向到另一个页面并绕过图库插件事件。知道如何强制点击这个吗?

Link

2 个答案:

答案 0 :(得分:6)

您可以取消绑定父div上的当前事件处理程序,允许链接单击通过:

$('div.more-photos').off('click');

答案 1 :(得分:1)

您可以将onclick事件绑定到它。

<a href="#" onclick="javascript: return false;">More</a>