Line 100: | Line 100: | ||
$("#searchform").submit(function (e){ | $("#searchform").submit(function (e){ | ||
$("#searchInput").val("SUSTech "+$("#searchInput").val()); | $("#searchInput").val("SUSTech "+$("#searchInput").val()); | ||
+ | }); | ||
+ | $('*[id]').click(function() { | ||
+ | console.log(this.hash); | ||
+ | if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') | ||
+ | || location.hostname == this.hostname) { | ||
+ | |||
+ | var target = $('[id="'+this.hash.substring(1)+'"]'); | ||
+ | target = target.length ? target : $('[name="' + this.hash.slice(1) +'"]'); | ||
+ | if (target.length) { | ||
+ | $('html,body').animate({ | ||
+ | scrollTop: target.offset().top-70 | ||
+ | }, 1000); | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
}); | }); | ||
</script> | </script> |
Revision as of 09:05, 11 October 2016