什么会导致 height() 返回负值? [英] What can cause height() to return as a negative value?
本文介绍了什么会导致 height() 返回负值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我查看元素高度的代码:
This is my code to see the height of an element:
console.log($(".divText").height()); // Returns negative value
console.log($(".divText").outerHeight()); // returns zero
我在点击事件上执行代码,页面显示元素,我选择了正确的元素并且没有涉及浮动.还有什么可能导致这种情况发生?
I have the code execute on a click event, the page displays the element, I am selecting the correct element and there are no floats involved. What else can cause this to happen?
推荐答案
把代码放在里面,同时确保 min-height 设置为 element 大于或等于实际高度;
Put that code inside and also make sure min-height set to element is greater or equal than actual height;
$(document).ready(function(){
//your code
});
这篇关于什么会导致 height() 返回负值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文