It is tempting to do it like this:
| document.getElementById('idOfTheDiv').style.width = newWidth; |
However this won't work and if you think about it, it is not strange either.
This is how to declare the width and height of a div in a stylesheet:
aDiv { width: 200px; height:100px; } |
And by looking at this we can see why the first example doesn't work and how to fix it. I.e. add 'px' when setting the width like this:
| document.getElementById('idOfTheDiv').style.width = newWidth + 'px'; |