Difference between revisions of "Template:SJTU-BioX-Shanghai/Alpha/Header"
Line 10: | Line 10: | ||
function(evnt){ | function(evnt){ | ||
var a = evnt.target.parentElement; | var a = evnt.target.parentElement; | ||
− | + | var id = a.attributes["href"].nodeValue; | |
− | var ele = | + | var ele = document.getElementById(id.slice(1, id.length)) |
− | console.log(ele | + | var top = ele.offsetTop |
− | scrollTo(0, | + | console.log(ele, top); |
+ | scrollTo(0, top-40); | ||
evnt.preventDefault(); | evnt.preventDefault(); | ||
} | } |
Revision as of 01:34, 17 August 2015