Difference between revisions of "Team:TU Delft/Header Test"
Line 354: | Line 354: | ||
</script> | </script> | ||
<script> | <script> | ||
− | + | $("a[href*=#]").on('click', function(event){ | |
− | + | var href = $(this).attr("href"); | |
− | + | if ( /(#.*)/.test(href) ){ | |
− | + | var hash = href.match(/(#.*)/)[0]; | |
− | + | var path = href.match(/([^#]*)/)[0]; | |
− | + | ||
− | + | if (window.location.pathname == path || path.length == 0){ | |
− | + | event.preventDefault(); | |
− | + | $('html,body').animate({scrollTop:$(this.hash).offset().top}, 1000); | |
− | + | window.location.hash = hash; | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}); | }); | ||
</script> | </script> | ||
</html> | </html> |
Revision as of 13:11, 28 July 2015