首页 > 代码库 > div 滚动定位代码
div 滚动定位代码
var thisheith;
$(function () {
var divid = ‘#14681-121320-197209‘;
$(divid).find("a").addClass("c-red").addClass("b");
$(divid).bind("click", function () {
change(this);
});
$(divid).click();
ScrollDiv();
});
function ScrollDiv() {
var ex = document.getElementById("nav");
ex.scrollTop = thisheith-200;
}
function change(elem) {
thisheith= getTop(elem);
}
function getTop(e) {
var offset = e.offsetTop;
if (e.offsetParent != null) {
offset += getTop(e.offsetParent);
}
return offset;
}
div 滚动定位代码