views:

84

answers:

1

How do I get the width in pixels of a HTML <div> element in javascript?

+4  A: 

try divElement.offsetWidth || divElement.clientWidth

and also you might as well want to try divElement.style.width

Note: divElement is the DOM element of your div which can be obtained by document.getElementById("yourDivId")

Mahesh Velaga