想解释之间有什么区别的offsetHeight,clientHeight和scrollHeight或offsetWidth,clientWidth和scrollWidth?
在客户端工作之前必须知道这种差异.否则他们的一半生命将用于修复UI.
小提琴或下面的内联:
function whatis(propType) {
var mainDiv = document.getElementById("MainDIV");
if (window.sampleDiv == null) {
var div = document.createElement("div");
window.sampleDiv = div;
}
div = window.sampleDiv;
var propTypeWidth = propType.toLowerCase() + "Width";
var propTypeHeight = propType + "Height";
var computedStyle = window.getComputedStyle(mainDiv, null);
var borderLeftWidth = computedStyle.getPropertyValue("border-left-width");
var borderTopWidth = computedStyle.getPropertyValue("border-top-width");
div.style.position = "absolute";
div.style.left = mainDiv.offsetLeft + Math.round(parseFloat((propType == "client") ? borderLeftWidth : 0)) + "px"; …Run Code Online (Sandbox Code Playgroud)<div id="c1" class="features" style="height:100px;width:100px;"></div>
<div id="c2" class="features" style="height:120px;width:100px;"></div>
<div id="c3" class="features" style="height:90px;width:100px;"></div>
<div...>
Run Code Online (Sandbox Code Playgroud)
我如何使用JQuery找到最短的div?
例如,上面会导致div id ="c3",因为它的高度是90px.
在 Bootstrap 崩溃的代码中,在hide()方法中,我看到以下行:
this.$element[dimension](this.$element[dimension]())[0].offsetHeight
我不明白最后的意义.offsetHeight是什么,除非它有副作用,因为它没有被分配给任何东西。它有副作用吗?