当前节点获取位置汇总

$(this).offset().top; //当前节点距离顶端高度
$(window).height(); //当前浏览器窗口高度
$(window).scrollTop(); //被隐藏的上部 高度
$("html,body").height(); //当前页面高度 
node.height(); //当前节点高度

 示例:

var node = $(this).find("div[class='category_over_box']"); //节点 
var nodeHeight = node.height(); //当前节点高度
var currentTop = $(this).offset().top; //当前节点距离顶端高度
var currentWinHidHeight = $(window).scrollTop(); //被隐藏的上部 高度
var currLastHeight = currentTop - currentWinHidHeight; //剩余高度 
node.css("top", "-" + (currLastHeight - 40) + "px");

 

posted @ 2013-12-11 10:52  xyzhuzhou  阅读(540)  评论(0编辑  收藏  举报