javascript - Smooth scroll except on specific class but fontawesome icon doesn't work -
i have script smooth scroll anchor of link don't want links of images fancybox affected:
/*====================================== = scroll anchor = ======================================*/ $(document).on('click', 'a', function(event){ if (!$(event.target).hasclass('fancybox')) { event.preventdefault(); $('html, body').animate({ scrolltop: $( $.attr(this, 'href') ).offset().top }, 500); } }); this html structure of image link:
<div class="grid-item grid-item--big"> <div class="gallery-image"> <a href="assets/images/tour-view/grid-images/fancybox-1.png" data-fancybox-group="gallery" class="title-hover dh-overlay fancybox"><i class="icons fa fa-eye"></i></a> <div class="bg"></div> </div> </div> the script works everywhere on page, , on image, when click script job , no scroll fired , fancybox image opened expected; except when click on font-awesome icon. in case nothing happens.
maybe should edit script, how? suggestion appreciated! in advance.
i've solved using new class , assigned elements want scroll to.
$(document).on('click', 'a', function(event){ if ($(event.target).hasclass('btn-book-tour') || $(event.target).hasclass('scrollto')) { event.preventdefault(); $('html, body').animate({ scrolltop: $( $.attr(this, 'href') ).offset().top }, 500); } });
Comments
Post a Comment