JQuery: scrolling stops before reaching element -


i'm using jquery's scrolltop scroll specific element but, weirdly, scrolling stops before reaching element. can have codepen have made.

here's html:

<div id="events">     <div id="event-list">         <div class="content">             <h2>vendredi 17 octobre</h2>             <ul id="event-1" class="event-title">                 list items             </ul>             <h2>vendredi 21 octobre</h2>             <ul id="event-2" class="event-title">                 list-items             </ul>         </div>     </div>      <div id="event-details">         <div class="content">             <section id="event-1" class="details">                 stuff             </section>              <section id="event-2" class="details">                 stuff             </section>         </div>     </div> </div> 

and jquery:

$(function(){   var thisoffset = $("#event-2").offset().top;   console.log(thisoffset)    $(".scroll").on("click", function(e){     console.log("scroll")      $("#event-details .content").animate({        scrolltop: thisoffset      }, 1000)      e.preventdefault();   }); }); 

any idea why , how solve issue? thank you!

you can use 1 time same id in html page. use event-2 2 times id, scrolls first one.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -