The other answers weren't working for me. Here's what I found at w3schools, assuming the div
has a height
and/or width
set.
All you need is height
and width
to exclude padding.
var height = document.getElementById('myDiv').style.height;
var width = document.getElementById('myDiv').style.width;
You downvoters: This answer has helped at least 5 people, judging by the upvotes I've received. If you don't like it, tell me why so I can fix it. That's my biggest pet peeve with downvotes; you rarely tell me why you downvote it.