jq获取div的高度
发布时间:2015-10-15, 14:39:04 分类:HTML | 编辑 off 网址 | 辅助
正文 843字数 76,287阅读
//获取当前IDV的高度
function getHeight(ele){
$(ele).addClass("active_cat");//增加样式
alert($(ele).height());
}
//获取当前div下面的子div的高度
function getChildH(ele){
$(ele).addClass("active_cat");
alert($(ele).children().find(".shadow_border").height());
}
/移除样式
function removeClass(ele){
$(ele).removeClass("active_cat");
}
function addClass(ele){
$(ele).addClass("active_cat");
if(parseInt(ele.offsetTop)+parseInt($(ele).children().find(".shadow_border").height())>parseInt(document.body.clientHeight)){
document.body.style.height = parseInt(ele.offsetTop)+parseInt($(ele).children().find(".shadow_border").height())+20;
}
}
<div onmouseover="getHeight(ele),getChildH()">
<div>
<div>
<div>
Run code
Cut to clipboard
(支付宝)给作者钱财以资鼓励 (微信)→
暂无评论 »