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

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -