Created
January 11, 2014 11:43
-
-
Save ultim8k/8369942 to your computer and use it in GitHub Desktop.
Get total width of a dom element (width + padding + margin + borders)
This file contains hidden or 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
function getTotalWidth(el){ | |
var width = el.width(); | |
var padding = parseInt(el.css("padding-left"), 10) + parseInt(el.css("padding-right"), 10); | |
var margin = parseInt(el.css("margin-left"), 10) + parseInt(el.css("margin-right"), 10); | |
var border = parseInt(el.css("borderLeftWidth"), 10) + parseInt(el.css("borderRightWidth"), 10); | |
return width + padding + margin + border; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment