Last active
August 29, 2015 14:06
-
-
Save monkindey/95f44ccc9e633f1c6b76 to your computer and use it in GitHub Desktop.
offsetheight clientheight scrollheight区别
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author monkindey | |
* @date 2014-09-23 | |
* @reference http://stackoverflow.com/questions/22675126/ | |
* what-is-offsetheight-clientheight-scrollheight | |
*/ | |
var $id = function(id){ | |
return document.getElementById(id); | |
}; | |
var box = $id('box'); | |
var height = [{ | |
name: 'clientHeight', | |
// visible height + padding = 303 | |
value: box.clientHeight | |
}, { | |
name: 'offsetHeight', | |
// clientHeight + border + scrollbar | |
value: box.offsetHeight | |
}, { | |
name: 'scrollHeight', | |
// clientHeight + non-visible height | |
value: box.scrollHeight | |
}]; | |
console.table(height); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment