
Change the height and width of an element: getElementById("myImg").Set the width of a element: getElementById("myBtn").The width and height properties set the element's width and height to the supplied values.3 How do I set the width of a dom? Height properties to set the width and height of an element, e.g. Let height = box.clientHeight document.getElementById("myElID").style.width = "100px" Īs we have seen, a large number of examples were utilised in order to solve the Javascript Set Element Width problem that was present. Javascript Set Element Width Further down, we will go over the remaining potential solutions. There is not just one way to solve a problem rather, there are many different ways that can be tried.

offsetHeight //includes margin,border,padding

Var height = document.getElementById('myID'). Var width = document.getElementById('myID').offsetWidth //includes margin,border,padding
