Skip to content Skip to sidebar Skip to footer

Resize And Repositon Div Using Javascript

I'm trying to do a simple resize and reposition of a div element that shows a ajax loading image. The content it loads can change size, so I want the div element to resize to be t

Solution 1:

I created a basic test page from the code you provided and couldn't reproduce the problem. This suggests there is something else going on in your page that is causing the behaviour you are seeing.

Could you take your page and pare it down to a minimal case that demonstrates the JavaScript error? You'll find performing this process often will reveal the cause of the error - you'll remove something and it will start working, indicating that something in that removed section of code is the source of the problem :)

Solution 2:

div.style.width is not valid property for accessing width of div.

use div.offsetWidth and div.offsetHeight for width and height respectively.

Post a Comment for "Resize And Repositon Div Using Javascript"