mardi 5 mai 2015

javascript scroll not working

I want my link to scroll down the page to the target content.

This is my script (inside the head tag):

<script type="text/javascript">
    jQuery(document).ready(function($) {
        $(".scroll").click(function(event){     
            event.preventDefault();
        $('html,body').animate({scrollTop:$(this.hash).offset().top},1200);
        });
    });
</script>

And these are my links (inside the body tag):

<%= link_to 'Plataformas', root_path + '#plataformas', class: "scroll" %>
<%= link_to 'Contato', root_path + '#contato', class: "scroll" %>

This chunks of code are inside my application.html.erb.

Thank you in advance!

Aucun commentaire:

Enregistrer un commentaire